commit def22db09679c1570e82eeb9e6ad75f8bfcfeb53 Author: Oswald Buddenhagen <o...@users.sf.net> Date: Sun Jul 28 21:13:28 2019 +0200
constness fixes add missing const qualifications, and add "const cast" suppressions where unavoidable. src/drv_maildir.c | 5 ++++- src/main.c | 8 ++++---- src/socket.c | 5 ++++- src/sync.c | 2 +- src/sync.h | 2 +- src/util.c | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/drv_maildir.c b/src/drv_maildir.c index 777280d..bb98d3f 100644 --- a/src/drv_maildir.c +++ b/src/drv_maildir.c @@ -649,7 +649,10 @@ static void make_key( const char *info_stop, DBT *tkey, const char *name ) { char *u = strpbrk( name, info_stop ); +DIAG_PUSH +DIAG_DISABLE("-Wcast-qual") // C has no const_cast<> ... tkey->data = (char *)name; +DIAG_POP tkey->size = u ? (size_t)(u - name) : strlen( name ); } #endif /* USE_DB */ @@ -844,7 +847,7 @@ maildir_set_uid( maildir_store_t *ctx, const char *name, uint *uid ) static int maildir_compare( const void *l, const void *r ) { - msg_t *lm = (msg_t *)l, *rm = (msg_t *)r; + const msg_t *lm = (const msg_t *)l, *rm = (const msg_t *)r; char *ldot, *rdot, *ldot2, *rdot2, *lseq, *rseq; int ret, llen, rlen; diff --git a/src/main.c b/src/main.c index c2420ef..d8ea02f 100644 --- a/src/main.c +++ b/src/main.c @@ -248,8 +248,8 @@ is_inbox( const char *name ) static int cmp_box_names( const void *a, const void *b ) { - const char *as = *(const char **)a; - const char *bs = *(const char **)b; + const char *as = *(const char * const *)a; + const char *bs = *(const char * const *)b; int ai = is_inbox( as ); int bi = is_inbox( bs ); int di = bi - ai; @@ -1087,14 +1087,14 @@ sync_listed_boxes( main_vars_t *mvars, box_ent_t *mbox ) if (!mvars->list) { nfasprintf( &mvars->names[M], "%s%s", mpfx, mbox->name ); nfasprintf( &mvars->names[S], "%s%s", spfx, mbox->name ); - sync_boxes( mvars->ctx, (const char **)mvars->names, mbox->present, mvars->chan, done_sync_2_dyn, mvars ); + sync_boxes( mvars->ctx, (const char * const *)mvars->names, mbox->present, mvars->chan, done_sync_2_dyn, mvars ); return 1; } printf( "%s%s <=> %s%s\n", mpfx, mbox->name, spfx, mbox->name ); } else { if (!mvars->list) { mvars->names[M] = mvars->names[S] = mbox->name; - sync_boxes( mvars->ctx, (const char **)mvars->names, mbox->present, mvars->chan, done_sync, mvars ); + sync_boxes( mvars->ctx, (const char * const *)mvars->names, mbox->present, mvars->chan, done_sync, mvars ); return 1; } puts( mbox->name ); diff --git a/src/socket.c b/src/socket.c index bf09e5e..42385f0 100644 --- a/src/socket.c +++ b/src/socket.c @@ -232,7 +232,10 @@ verify_cert_host( const server_conf_t *conf, conn_t *sock ) static int init_ssl_ctx( const server_conf_t *conf ) { +DIAG_PUSH +DIAG_DISABLE("-Wcast-qual") // C has no 'mutable' or const_cast<> ... server_conf_t *mconf = (server_conf_t *)conf; +DIAG_POP if (conf->SSLContext) return conf->ssl_ctx_valid; @@ -320,7 +323,7 @@ socket_start_tls( conn_t *conn, void (*cb)( int ok, void *aux ) ) } init_wakeup( &conn->ssl_fake, ssl_fake_cb, conn ); - if (!(conn->ssl = SSL_new( ((server_conf_t *)conn->conf)->SSLContext ))) { + if (!(conn->ssl = SSL_new( ((server_conf_t const *)conn->conf)->SSLContext ))) { print_ssl_errors( "initializing SSL connection" ); start_tls_p3( conn, 0 ); return; diff --git a/src/sync.c b/src/sync.c index cf788f0..4508ac1 100644 --- a/src/sync.c +++ b/src/sync.c @@ -1002,7 +1002,7 @@ static void box_opened2( sync_vars_t *svars, int t ); static void load_box( sync_vars_t *svars, int t, uint minwuid, uint_array_t mexcs ); void -sync_boxes( store_t *ctx[], const char *names[], int present[], channel_conf_t *chan, +sync_boxes( store_t *ctx[], const char * const names[], int present[], channel_conf_t *chan, void (*cb)( int sts, void *aux ), void *aux ) { sync_vars_t *svars; diff --git a/src/sync.h b/src/sync.h index be26660..9b904c3 100644 --- a/src/sync.h +++ b/src/sync.h @@ -80,7 +80,7 @@ extern const char *str_ms[2], *str_hl[2]; #define BOX_PRESENT 1 /* All passed pointers must stay alive until cb is called. */ -void sync_boxes( store_t *ctx[], const char *names[], int present[], channel_conf_t *chan, +void sync_boxes( store_t *ctx[], const char * const names[], int present[], channel_conf_t *chan, void (*cb)( int sts, void *aux ), void *aux ); #endif diff --git a/src/util.c b/src/util.c index 878ee40..738254d 100644 --- a/src/util.c +++ b/src/util.c @@ -541,7 +541,7 @@ map_name( const char *arg, char **result, int reserve, const char *in, const cha static int compare_uints( const void *l, const void *r ) { - uint li = *(uint *)l, ri = *(uint *)r; + uint li = *(const uint *)l, ri = *(const uint *)r; if (li != ri) // Can't subtract, the result might not fit into signed int. return li > ri ? 1 : -1; return 0; _______________________________________________ isync-devel mailing list isync-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/isync-devel