Browse Source

constness fixes

add missing const qualifications, and add "const cast" suppressions
where unavoidable.
1.4
Oswald Buddenhagen 5 years ago
parent
commit
def22db096
  1. 5
      src/drv_maildir.c
  2. 8
      src/main.c
  3. 5
      src/socket.c
  4. 2
      src/sync.c
  5. 2
      src/sync.h
  6. 2
      src/util.c

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

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

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

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

2
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

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

Loading…
Cancel
Save