Skip to content

Commit 1c7dc1c

Browse files
authored
fix: windows compile warnings (#257)
* fix: misc debug warnings * fix: warnings in call_out code * fix: disassemble warnings * fix: ed warnings * fix: linux warnings * fix: remove obsoleted inet_ntoa * fix: socket efun warnings
1 parent 8ecb713 commit 1c7dc1c

13 files changed

Lines changed: 284 additions & 294 deletions

File tree

docs/applies/master/valid_socket.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,19 @@ int valid_socket (object caller, string function, mixed *info);
1111
Each of the socket efuns calls `valid_socket()` prior to executing.
1212
If `valid_socket()` returns 0, then the socket efun fails.
1313
If `valid_socket()` returns 1, then the socket efun attempts to succeed.
14+
1415
The first argument **caller** is the object that called the socket efun.
15-
The second argument is the name of the socket efun that is being called (e.g. `socket_write()` or `socket_bind()`).
16+
The second argument is the name of the socket function that being called, which is one of below:
17+
- `"create"` when [socket_create()](../../efuns/socket_create.md) is called.
18+
- `"bind"` when [socket_bind()](../../efuns/socket_bind.md) is called.
19+
- `"listen"` when [socket_listen()](../../efuns/socket_listen.md) is called.
20+
- `"accept"` when [socket_accept()](../../efuns/socket_accept.md) is called.
21+
- `"connect"` when [socket_connect()](../../efuns/socket_connect.md) is called.
22+
- `"write"` when [socket_write()](../../efuns/socket_write.md) is called.
23+
- `"close"` when [socket_close()](../../efuns/socket_close.md) is called.
24+
- `"release"` when [socket_release()](../../efuns/socket_release.md) is called.
25+
- `"acquire"` when [socket_acquire()](../../efuns/socket_acquire.md) is called.
26+
1627
The third argument is an array of information.
1728
The first element of the array (when applicable) is file descriptor being referenced.
1829
The second element of the array is the owner of the socket (object).

docs/efuns/socket_create.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,41 @@
55
## SYNOPSIS
66
~~~cxx
77
#include <socket_err.h>
8-
~~~
98

10-
int socket_create( int mode, string read_callback,
11-
void | string close_callback );
9+
int socket_create (int mode, string read_callback, void | string close_callback);
10+
~~~
1211
1312
## DESCRIPTION
1413
socket_create() creates an efun socket. mode determines
1514
which type of socket is created. Currently supported socket
1615
modes are:
1716
18-
MUD for sending LPC data types using TCP protocol.
19-
20-
STREAM for sending raw data using TCP protocol.
21-
22-
DATAGRAM for using UDP protocol.
17+
- `MUD` for sending LPC data types using TCP protocol.
18+
- `STREAM` for sending raw data using TCP protocol.
19+
- `DATAGRAM` for using UDP protocol.
2320
24-
The argument read_callback is the name of a function for the
21+
The argument `read_callback` is the name of a function for the
2522
driver to call when the socket gets data from its peer. The
2623
read callback should follow this format:
2724
25+
~~~cxx
2826
void read_callback(int fd, mixed message)
27+
~~~
2928

30-
Where fd is the socket which received the data, and message
29+
Where `fd` is the socket which received the data, and `message`
3130
is the data which was received.
3231

33-
The argument close_callback is the name of a function for
32+
The argument `close_callback` is the name of a function for
3433
the driver to call if the socket closes unexpectedly, i.e.
3534
not as the result of a [socket_close()](socket_close.md) call. The close
3635
callback should follow this format:
3736

37+
~~~cxx
3838
void close_callback(int fd)
39+
~~~
3940
40-
Where fd is the socket which has closed. NOTE:
41-
close_callback is not used with DATAGRAM mode sockets.
41+
Where `fd` is the socket which has closed.
42+
NOTE: `close_callback` is not used with `DATAGRAM` mode sockets.
4243
4344
## RETURN VALUE
4445
socket_create() returns:

lib/efuns/call_out.c

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
typedef struct pending_call_s
1717
{
18-
int delta;
18+
time_t delta;
1919
string_or_func_t function;
2020
object_t *ob;
2121
array_t *vs;
@@ -29,7 +29,8 @@ pending_call_t;
2929

3030
static pending_call_t *call_list[CALLOUT_CYCLE_SIZE];
3131
static pending_call_t *call_list_free;
32-
static int num_call, call_out_time = 0;
32+
static time_t call_out_time = 0;
33+
static int num_call;
3334
static int unique = 0;
3435

3536
static void free_call (pending_call_t *);
@@ -71,13 +72,10 @@ free_call (pending_call_t * cop)
7172
}
7273

7374

74-
/*
75+
/**
7576
* Setup a new call out.
7677
*/
77-
int
78-
new_call_out (object_t * ob, svalue_t * fun, int delay, int num_args,
79-
svalue_t * arg)
80-
{
78+
int new_call_out (object_t * ob, svalue_t * fun, time_t delay, int num_args, svalue_t* arg) {
8179
pending_call_t *cop, **copp;
8280
int tm;
8381

@@ -129,8 +127,7 @@ new_call_out (object_t * ob, svalue_t * fun, int delay, int num_args,
129127

130128
/* Find out which slot this one fits in */
131129
tm = (delay + current_time) & (CALLOUT_CYCLE_SIZE - 1);
132-
delay =
133-
(1 + (delay + current_time - call_out_time - 1) / CALLOUT_CYCLE_SIZE);
130+
delay = (1 + (delay + current_time - call_out_time - 1) / CALLOUT_CYCLE_SIZE);
134131

135132
for (copp = &call_list[tm]; *copp; copp = &(*copp)->next)
136133
{
@@ -269,9 +266,7 @@ call_out ()
269266
}
270267

271268

272-
static int
273-
time_left (int slot, int delay)
274-
{
269+
static time_t time_left (int slot, time_t delay) {
275270
int current_slot = call_out_time & (CALLOUT_CYCLE_SIZE - 1);
276271
if (slot > current_slot)
277272
{
@@ -291,11 +286,9 @@ time_left (int slot, int delay)
291286
* The time left until execution is returned.
292287
* -1 is returned if no call out pending.
293288
*/
294-
int
295-
remove_call_out (object_t * ob, char *fun)
296-
{
289+
int remove_call_out (object_t * ob, char *fun) {
297290
pending_call_t **copp, *cop;
298-
int delay;
291+
time_t delay;
299292
int i;
300293

301294
if (!ob)
@@ -313,21 +306,18 @@ remove_call_out (object_t * ob, char *fun)
313306
cop->next->delta += cop->delta;
314307
*copp = cop->next;
315308
free_call (cop);
316-
return time_left (i, delay);
309+
return (int)time_left (i, delay);
317310
}
318311
}
319312
}
320313
return -1;
321314
}
322315

323-
int
324-
remove_call_out_by_handle (int handle)
325-
{
316+
int remove_call_out_by_handle (int handle) {
326317
pending_call_t **copp, *cop;
327-
int delay = 0;
318+
time_t delay = 0;
328319

329-
for (copp = &call_list[handle & (CALLOUT_CYCLE_SIZE - 1)]; *copp;
330-
copp = &(*copp)->next)
320+
for (copp = &call_list[handle & (CALLOUT_CYCLE_SIZE - 1)]; *copp; copp = &(*copp)->next)
331321
{
332322
delay += (*copp)->delta;
333323
if ((*copp)->handle == handle)
@@ -337,33 +327,29 @@ remove_call_out_by_handle (int handle)
337327
cop->next->delta += cop->delta;
338328
*copp = cop->next;
339329
free_call (cop);
340-
return time_left (handle & (CALLOUT_CYCLE_SIZE - 1), delay);
330+
return (int)time_left (handle & (CALLOUT_CYCLE_SIZE - 1), delay);
341331
}
342332
}
343333
return -1;
344334
}
345335

346-
int
347-
find_call_out_by_handle (int handle)
348-
{
336+
int find_call_out_by_handle (int handle) {
349337
pending_call_t *cop;
350-
int delay = 0;
338+
time_t delay = 0;
351339

352340
for (cop = call_list[handle & (CALLOUT_CYCLE_SIZE - 1)]; cop;
353341
cop = cop->next)
354342
{
355343
delay += cop->delta;
356344
if (cop->handle == handle)
357-
return time_left (handle & (CALLOUT_CYCLE_SIZE - 1), delay);
345+
return (int)time_left (handle & (CALLOUT_CYCLE_SIZE - 1), delay);
358346
}
359347
return -1;
360348
}
361349

362-
int
363-
find_call_out (object_t * ob, char *fun)
364-
{
350+
int find_call_out (object_t * ob, char *fun) {
365351
pending_call_t *cop;
366-
int delay;
352+
time_t delay;
367353
int i;
368354

369355
if (!ob)
@@ -375,7 +361,7 @@ find_call_out (object_t * ob, char *fun)
375361
{
376362
delay += cop->delta;
377363
if (cop->ob == ob && strcmp (cop->function.s, fun) == 0)
378-
return time_left (i, delay);
364+
return (int)time_left (i, delay);
379365
}
380366
}
381367
return -1;
@@ -415,10 +401,9 @@ print_call_out_usage (outbuffer_t * ob, int verbose)
415401
* 1: The function (string).
416402
* 2: The delay.
417403
*/
418-
array_t *
419-
get_all_call_outs ()
420-
{
421-
int i, j, delay, tm;
404+
array_t* get_all_call_outs () {
405+
time_t delay;
406+
int i, j, tm;
422407
pending_call_t *cop;
423408
array_t *v;
424409

@@ -520,7 +505,7 @@ void f_call_out (void) {
520505

521506
if (!(current_object->flags & O_DESTRUCTED))
522507
{
523-
ret = new_call_out (current_object, arg, arg[1].u.number, num, arg + 2);
508+
ret = new_call_out (current_object, arg, (time_t)arg[1].u.number, num, arg + 2);
524509
/* args have been transfered; don't free them;
525510
also don't need to free the int */
526511
sp -= num + 1;
@@ -537,7 +522,7 @@ void f_call_out (void) {
537522
#else
538523
if (!(current_object->flags & O_DESTRUCTED))
539524
{
540-
new_call_out (current_object, arg, arg[1].u.number, num, arg + 2);
525+
new_call_out (current_object, arg, (time_t)arg[1].u.number, num, arg + 2);
541526
sp -= num + 1;
542527
}
543528
else
@@ -557,7 +542,7 @@ void f_find_call_out (void) {
557542
#ifdef CALLOUT_HANDLES
558543
if (sp->type == T_NUMBER)
559544
{
560-
i = find_call_out_by_handle (sp->u.number);
545+
i = find_call_out_by_handle ((int)sp->u.number);
561546
}
562547
else
563548
{ /* T_STRING */
@@ -588,7 +573,7 @@ void f_remove_call_out (void) {
588573
}
589574
else
590575
{
591-
i = remove_call_out_by_handle (sp->u.number);
576+
i = remove_call_out_by_handle ((int)sp->u.number);
592577
}
593578
#endif
594579
}

lib/efuns/call_out.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
void call_out(void);
55
int find_call_out_by_handle(int);
66
int remove_call_out_by_handle(int);
7-
int new_call_out(object_t *, svalue_t *, int, int, svalue_t *);
7+
int new_call_out(object_t *, svalue_t *, time_t, int, svalue_t *);
88
int remove_call_out(object_t *, char *);
99
void remove_all_call_out(object_t *);
1010
int find_call_out(object_t *, char *);

lib/efuns/debug.c

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ void f_cache_stats (void) {
8282

8383
#ifdef F_CALL_STACK
8484
void f_call_stack (void) {
85-
int i, n = csp - &control_stack[0] + 1;
85+
int i;
86+
int n = (int)(csp - &control_stack[0] + 1);
8687
array_t *ret;
8788

8889
if (sp->u.number < 0 || sp->u.number > 3)
@@ -256,14 +257,13 @@ f_malloc_status (void)
256257

257258

258259
#ifdef F_MUD_STATUS
259-
void
260-
f_mud_status (void)
261-
{
262-
int tot, res, verbose = 0;
260+
void f_mud_status (void) {
261+
size_t tot;
262+
int res, verbose = 0;
263263
outbuffer_t ob;
264264

265265
outbuf_zero (&ob);
266-
verbose = (sp--)->u.number;
266+
verbose = (int)(sp--)->u.number;
267267

268268
if (reserved_area)
269269
res = CONFIG_INT (__RESERVED_MEM_SIZE__);
@@ -359,15 +359,14 @@ f_dump_file_descriptors (void)
359359

360360

361361
#ifdef F_MEMORY_INFO
362-
void
363-
f_memory_info (void)
364-
{
362+
void f_memory_info (void) {
365363
int mem;
366364
object_t *ob;
367365

368366
if (st_num_arg == 0)
369367
{
370-
int res, tot;
368+
int res;
369+
size_t tot;
371370

372371
if (reserved_area)
373372
res = CONFIG_INT (__RESERVED_MEM_SIZE__);
@@ -402,12 +401,10 @@ f_memory_info (void)
402401

403402

404403
#ifdef F_MEMORY_SUMMARY
405-
static int memory_share (svalue_t *);
404+
static size_t memory_share (svalue_t *);
406405

407-
static int
408-
node_share (mapping_t * m, mapping_node_t * elt, void *tp)
409-
{
410-
int *t = (int *) tp;
406+
static int node_share (mapping_t * m, mapping_node_t * elt, void *tp) {
407+
size_t *t = (size_t *) tp;
411408
(void)m; /* unused */
412409

413410
*t += sizeof (mapping_node_t) - 2 * sizeof (svalue_t);
@@ -417,11 +414,9 @@ node_share (mapping_t * m, mapping_node_t * elt, void *tp)
417414
return 0;
418415
}
419416

420-
static int
421-
memory_share (svalue_t * sv)
422-
{
423-
int i, total = sizeof (svalue_t);
424-
int subtotal;
417+
static size_t memory_share (svalue_t * sv) {
418+
size_t total = sizeof (svalue_t), subtotal;
419+
int i;
425420

426421
switch (sv->type)
427422
{
@@ -458,8 +453,7 @@ memory_share (svalue_t * sv)
458453
tmp.u.arr = sv->u.fp->hdr.args;
459454

460455
if (tmp.u.arr)
461-
subtotal =
462-
sizeof (funptr_hdr_t) + memory_share (&tmp) - sizeof (svalue_t);
456+
subtotal = sizeof (funptr_hdr_t) + memory_share (&tmp) - sizeof (svalue_t);
463457
else
464458
subtotal = sizeof (funptr_hdr_t);
465459
switch (sv->u.fp->hdr.type)
@@ -509,7 +503,7 @@ fms_recurse (mapping_t * map, object_t * ob, int *idx, program_t * prog)
509503

510504
for (i = 0; i < prog->num_variables_defined; i++)
511505
{
512-
int size = memory_share (ob->variables + *idx + i);
506+
size_t size = memory_share (ob->variables + *idx + i);
513507

514508
sv.u.string = prog->variable_table[i];
515509
entry = find_for_insert (map, &sv, 0);

0 commit comments

Comments
 (0)