Shutup many compiler warnings
From: Stefan Bühler <stbuehler@web.de>
- Unused vars
- Conversion between object and function pointer (solved with intptr_t)
- Wrong signedness
---
src/fdevent.c | 4 ++--
src/fdevent_select.c | 1 -
src/http_auth.c | 22 +++++++++++-----------
src/lemon.c | 13 +++++++------
src/lempar.c | 10 ++++++----
src/log.c | 2 +-
src/mod_sql_vhost_core.c | 3 ++-
src/plugin.c | 2 +-
src/server.c | 8 +++++---
src/stat_cache.c | 6 ++++++
10 files changed, 41 insertions(+), 30 deletions(-)
diff --git a/src/fdevent.c b/src/fdevent.c
index d513620..e939555 100644
|
a
|
b
|
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | int fdevent_poll(fdevents *ev, int timeout_ms) { |
| 343 | | if (ev->poll == NULL) SEGFAULT("ev->poll is %p", ev->poll); |
| | 343 | if (ev->poll == NULL) SEGFAULT("ev->poll is %p", (void*) (intptr_t) ev->poll); |
| 344 | 344 | return ev->poll(ev, timeout_ms); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | int fdevent_get_revents(fdevents *ev, size_t event_count, fdevent_revents *revents) { |
| 348 | 348 | size_t i; |
| 349 | 349 | |
| 350 | | if (ev->get_revents == NULL) SEGFAULT("ev->get_revents is %p", ev->get_revents); |
| | 350 | if (ev->get_revents == NULL) SEGFAULT("ev->get_revents is %p", (void*) (intptr_t) ev->get_revents); |
| 351 | 351 | |
| 352 | 352 | fdevent_revents_reset(revents); |
| 353 | 353 | |
diff --git a/src/fdevent_select.c b/src/fdevent_select.c
index c0142b7..fee7ec4 100644
|
a
|
b
|
|
| 54 | 54 | static int fdevent_select_event_add(fdevents *ev, iosocket *sock, int events) { |
| 55 | 55 | /* we should be protected by max-fds, but you never know */ |
| 56 | 56 | #ifndef _WIN32 |
| 57 | | u_int i; |
| 58 | 57 | assert(sock->fd < FD_SETSIZE); |
| 59 | 58 | #endif |
| 60 | 59 | |
diff --git a/src/http_auth.c b/src/http_auth.c
index 08bc68f..880c579 100644
|
a
|
b
|
|
| 487 | 487 | /* |
| 488 | 488 | * The password first, since that is what is most unknown |
| 489 | 489 | */ |
| 490 | | MD5_Update(&ctx, pw, strlen(pw)); |
| | 490 | MD5_Update(&ctx, (const unsigned char*) pw, strlen(pw)); |
| 491 | 491 | |
| 492 | 492 | /* |
| 493 | 493 | * Then our magic string |
| 494 | 494 | */ |
| 495 | | MD5_Update(&ctx, APR1_ID, strlen(APR1_ID)); |
| | 495 | MD5_Update(&ctx, (const unsigned char*) APR1_ID, strlen(APR1_ID)); |
| 496 | 496 | |
| 497 | 497 | /* |
| 498 | 498 | * Then the raw salt |
| 499 | 499 | */ |
| 500 | | MD5_Update(&ctx, sp, sl); |
| | 500 | MD5_Update(&ctx, (const unsigned char*) sp, sl); |
| 501 | 501 | |
| 502 | 502 | /* |
| 503 | 503 | * Then just as many characters of the MD5(pw, salt, pw) |
| 504 | 504 | */ |
| 505 | 505 | MD5_Init(&ctx1); |
| 506 | | MD5_Update(&ctx1, pw, strlen(pw)); |
| 507 | | MD5_Update(&ctx1, sp, sl); |
| 508 | | MD5_Update(&ctx1, pw, strlen(pw)); |
| | 506 | MD5_Update(&ctx1, (const unsigned char*) pw, strlen(pw)); |
| | 507 | MD5_Update(&ctx1, (const unsigned char*) sp, sl); |
| | 508 | MD5_Update(&ctx1, (const unsigned char*) pw, strlen(pw)); |
| 509 | 509 | MD5_Final(final, &ctx1); |
| 510 | 510 | for (pl = strlen(pw); pl > 0; pl -= APR_MD5_DIGESTSIZE) { |
| 511 | 511 | MD5_Update(&ctx, final, |
| … |
… |
|
| 525 | 525 | MD5_Update(&ctx, final, 1); |
| 526 | 526 | } |
| 527 | 527 | else { |
| 528 | | MD5_Update(&ctx, pw, 1); |
| | 528 | MD5_Update(&ctx, (const unsigned char*) pw, 1); |
| 529 | 529 | } |
| 530 | 530 | } |
| 531 | 531 | |
| … |
… |
|
| 547 | 547 | for (i = 0; i < 1000; i++) { |
| 548 | 548 | MD5_Init(&ctx1); |
| 549 | 549 | if (i & 1) { |
| 550 | | MD5_Update(&ctx1, pw, strlen(pw)); |
| | 550 | MD5_Update(&ctx1, (const unsigned char*) pw, strlen(pw)); |
| 551 | 551 | } |
| 552 | 552 | else { |
| 553 | 553 | MD5_Update(&ctx1, final, APR_MD5_DIGESTSIZE); |
| 554 | 554 | } |
| 555 | 555 | if (i % 3) { |
| 556 | | MD5_Update(&ctx1, sp, sl); |
| | 556 | MD5_Update(&ctx1, (const unsigned char*) sp, sl); |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | if (i % 7) { |
| 560 | | MD5_Update(&ctx1, pw, strlen(pw)); |
| | 560 | MD5_Update(&ctx1, (const unsigned char*) pw, strlen(pw)); |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | if (i & 1) { |
| 564 | 564 | MD5_Update(&ctx1, final, APR_MD5_DIGESTSIZE); |
| 565 | 565 | } |
| 566 | 566 | else { |
| 567 | | MD5_Update(&ctx1, pw, strlen(pw)); |
| | 567 | MD5_Update(&ctx1, (const unsigned char*) pw, strlen(pw)); |
| 568 | 568 | } |
| 569 | 569 | MD5_Final(final,&ctx1); |
| 570 | 570 | } |
diff --git a/src/lemon.c b/src/lemon.c
index 5dcf144..504be52 100644
|
a
|
b
|
|
| 11 | 11 | #include <string.h> |
| 12 | 12 | #include <ctype.h> |
| 13 | 13 | #include <stdlib.h> |
| | 14 | #include <unistd.h> |
| 14 | 15 | |
| 15 | 16 | extern void qsort(); |
| 16 | 17 | extern double strtod(); |
| … |
… |
|
| 976 | 977 | ** If either action is a SHIFT, then it must be apx. This |
| 977 | 978 | ** function won't work if apx->type==REDUCE and apy->type==SHIFT. |
| 978 | 979 | */ |
| 979 | | static int resolve_conflict(apx,apy,errsym) |
| | 980 | static int resolve_conflict(apx,apy) |
| 980 | 981 | struct action *apx; |
| 981 | 982 | struct action *apy; |
| 982 | | struct symbol *errsym; /* The error symbol (if defined. NULL otherwise) */ |
| 983 | 983 | { |
| 984 | 984 | struct symbol *spx, *spy; |
| 985 | 985 | int errcnt = 0; |
| … |
… |
|
| 1326 | 1326 | int argc; |
| 1327 | 1327 | char **argv; |
| 1328 | 1328 | { |
| | 1329 | ( (void) argc ); // UNUSED(argc) |
| 1329 | 1330 | static int version = 0; |
| 1330 | 1331 | static int rpflag = 0; |
| 1331 | 1332 | static int basisflag = 0; |
| … |
… |
|
| 1651 | 1652 | }else if( op[j].type==OPT_FLAG ){ |
| 1652 | 1653 | *((int*)op[j].arg) = v; |
| 1653 | 1654 | }else if( op[j].type==OPT_FFLAG ){ |
| 1654 | | (*(void(*)())(op[j].arg))(v); |
| | 1655 | (*(void(*)())((intptr_t)op[j].arg))(v); |
| 1655 | 1656 | }else{ |
| 1656 | 1657 | if( err ){ |
| 1657 | 1658 | fprintf(err,"%smissing argument on switch.\n",emsg); |
| … |
… |
|
| 1733 | 1734 | *(double*)(op[j].arg) = dv; |
| 1734 | 1735 | break; |
| 1735 | 1736 | case OPT_FDBL: |
| 1736 | | (*(void(*)())(op[j].arg))(dv); |
| | 1737 | (*(void(*)())((intptr_t)op[j].arg))(dv); |
| 1737 | 1738 | break; |
| 1738 | 1739 | case OPT_INT: |
| 1739 | 1740 | *(int*)(op[j].arg) = lv; |
| 1740 | 1741 | break; |
| 1741 | 1742 | case OPT_FINT: |
| 1742 | | (*(void(*)())(op[j].arg))((int)lv); |
| | 1743 | (*(void(*)())((intptr_t)op[j].arg))((int)lv); |
| 1743 | 1744 | break; |
| 1744 | 1745 | case OPT_STR: |
| 1745 | 1746 | *(char**)(op[j].arg) = sv; |
| 1746 | 1747 | break; |
| 1747 | 1748 | case OPT_FSTR: |
| 1748 | | (*(void(*)())(op[j].arg))(sv); |
| | 1749 | (*(void(*)())((intptr_t)op[j].arg))(sv); |
| 1749 | 1750 | break; |
| 1750 | 1751 | } |
| 1751 | 1752 | } |
diff --git a/src/lempar.c b/src/lempar.c
index 9ab9075..07bb790 100644
|
a
|
b
|
|
| 210 | 210 | */ |
| 211 | 211 | const char *ParseTokenName(int tokenType){ |
| 212 | 212 | #ifndef NDEBUG |
| 213 | | if( tokenType>0 && tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){ |
| | 213 | if( tokenType>0 && ((unsigned int)tokenType)<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){ |
| 214 | 214 | return yyTokenName[tokenType]; |
| 215 | 215 | }else{ |
| 216 | 216 | return "Unknown"; |
| … |
… |
|
| 335 | 335 | return YY_NO_ACTION; |
| 336 | 336 | } |
| 337 | 337 | i += iLookAhead; |
| 338 | | if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ |
| | 338 | if( i<0 || (unsigned int)i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ |
| 339 | 339 | #ifdef YYFALLBACK |
| 340 | 340 | int iFallback; /* Fallback token */ |
| 341 | 341 | if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) |
| … |
… |
|
| 378 | 378 | return YY_NO_ACTION; |
| 379 | 379 | } |
| 380 | 380 | i += iLookAhead; |
| 381 | | if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ |
| | 381 | if( i<0 || (unsigned int)i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ |
| 382 | 382 | return yy_default[stateno]; |
| 383 | 383 | }else{ |
| 384 | 384 | return yy_action[i]; |
| … |
… |
|
| 456 | 456 | yymsp = &yypParser->yystack[yypParser->yyidx]; |
| 457 | 457 | #ifndef NDEBUG |
| 458 | 458 | if( yyTraceFILE && yyruleno>=0 |
| 459 | | && yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){ |
| | 459 | && (unsigned int) yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){ |
| 460 | 460 | fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, |
| 461 | 461 | yyRuleName[yyruleno]); |
| 462 | 462 | } |
| … |
… |
|
| 511 | 511 | int yymajor, /* The major type of the error token */ |
| 512 | 512 | YYMINORTYPE yyminor /* The minor type of the error token */ |
| 513 | 513 | ){ |
| | 514 | ( (void) yymajor ); |
| | 515 | ( (void) yyminor ); |
| 514 | 516 | ParseARG_FETCH; |
| 515 | 517 | #define TOKEN (yyminor.yy0) |
| 516 | 518 | %% |
diff --git a/src/log.c b/src/log.c
index 341fc03..d1f166f 100644
|
a
|
b
|
|
| 321 | 321 | l = vsnprintf(b->ptr, b->size, fmt, ap); |
| 322 | 322 | va_end(ap); |
| 323 | 323 | |
| 324 | | if (l > -1 && l < b->size) { |
| | 324 | if (l > -1 && ((unsigned int) l) < b->size) { |
| 325 | 325 | b->used = l + 1; |
| 326 | 326 | |
| 327 | 327 | break; |
diff --git a/src/mod_sql_vhost_core.c b/src/mod_sql_vhost_core.c
index b9dedba..1e90929 100644
|
a
|
b
|
|
| 333 | 333 | |
| 334 | 334 | #ifdef HAVE_GLIB_H |
| 335 | 335 | static gboolean cached_vhost_remove_expired(gpointer _key, gpointer _val, gpointer data) { |
| 336 | | buffer *key = _key; |
| | 336 | // buffer *key = _key; |
| | 337 | UNUSED(_key); |
| 337 | 338 | cached_vhost *val = _val; |
| 338 | 339 | server *srv = data; |
| 339 | 340 | |
diff --git a/src/plugin.c b/src/plugin.c
index aff2f12..0941c2c 100644
|
a
|
b
|
|
| 298 | 298 | |
| 299 | 299 | #else |
| 300 | 300 | #if 1 |
| 301 | | init = (int (*)(plugin *))dlsym(p->lib, srv->tmp_buf->ptr); |
| | 301 | init = (int (*)(plugin *))(intptr_t)dlsym(p->lib, srv->tmp_buf->ptr); |
| 302 | 302 | #else |
| 303 | 303 | *(void **)(&init) = dlsym(p->lib, srv->tmp_buf->ptr); |
| 304 | 304 | #endif |
diff --git a/src/server.c b/src/server.c
index 911b096..19f0ec7 100644
|
a
|
b
|
|
| 113 | 113 | switch (sig) { |
| 114 | 114 | case SIGTERM: |
| 115 | 115 | srv_shutdown = 1; |
| 116 | | memcpy(&last_sigterm_info, si, sizeof(*si)); |
| | 116 | memcpy((siginfo_t*) &last_sigterm_info, si, sizeof(*si)); |
| 117 | 117 | break; |
| 118 | 118 | case SIGINT: |
| 119 | 119 | if (graceful_shutdown) { |
| … |
… |
|
| 122 | 122 | graceful_shutdown = 1; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | | memcpy(&last_sigterm_info, si, sizeof(*si)); |
| | 125 | memcpy((siginfo_t*) &last_sigterm_info, si, sizeof(*si)); |
| 126 | 126 | |
| 127 | 127 | break; |
| 128 | 128 | case SIGALRM: |
| … |
… |
|
| 130 | 130 | break; |
| 131 | 131 | case SIGHUP: |
| 132 | 132 | handle_sig_hup = 1; |
| 133 | | memcpy(&last_sighup_info, si, sizeof(*si)); |
| | 133 | memcpy((siginfo_t*) &last_sighup_info, si, sizeof(*si)); |
| 134 | 134 | break; |
| 135 | 135 | case SIGCHLD: |
| 136 | 136 | break; |
| … |
… |
|
| 1036 | 1036 | int need_joblist_queue_thread = 0; |
| 1037 | 1037 | GThread **stat_cache_threads; |
| 1038 | 1038 | GThread **aio_write_threads = NULL; |
| | 1039 | #ifdef USE_LINUX_AIO_SENDFILE |
| 1039 | 1040 | GThread *linux_aio_read_thread_id = NULL; |
| | 1041 | #endif |
| 1040 | 1042 | GThread * joblist_queue_thread_id = NULL; |
| 1041 | 1043 | GError *gerr = NULL; |
| 1042 | 1044 | #endif |
diff --git a/src/stat_cache.c b/src/stat_cache.c
index 9d1671b..27e6a78 100644
|
a
|
b
|
|
| 194 | 194 | |
| 195 | 195 | #ifdef HAVE_GLIB_H |
| 196 | 196 | gboolean stat_cache_free_hrfunc(gpointer _key, gpointer _value, gpointer _user_data) { |
| | 197 | UNUSED(_user_data); |
| 197 | 198 | stat_cache_entry *sce = _value; |
| 198 | 199 | buffer *b = _key; |
| 199 | 200 | |
| … |
… |
|
| 243 | 244 | #ifdef HAVE_SYS_INOTIFY_H |
| 244 | 245 | case STAT_CACHE_ENGINE_INOTIFY: |
| 245 | 246 | return stat_cache_handle_fdevent_inotify(_srv, _fce, revent); |
| | 247 | #else |
| | 248 | UNUSED(_fce); |
| | 249 | UNUSED(revent); |
| 246 | 250 | #endif |
| 247 | 251 | default: |
| 248 | 252 | return HANDLER_GO_ON; |
| … |
… |
|
| 262 | 266 | #endif |
| 263 | 267 | |
| 264 | 268 | static int stat_cache_entry_is_current(server *srv, stat_cache_entry *sce) { |
| | 269 | UNUSED(srv); |
| | 270 | UNUSED(sce); |
| 265 | 271 | return 1; |
| 266 | 272 | } |
| 267 | 273 | |