constness fixes

add missing const qualifications, and add "const cast" suppressions
where unavoidable.
This commit is contained in:
Oswald Buddenhagen 2019-07-28 21:13:28 +02:00
parent 5c2e8d3e14
commit def22db096
6 changed files with 15 additions and 9 deletions

View File

@ -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;

View File

@ -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 );

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;