From 64e5f07ad3371fa5e10fc0ad715a68205f4effb7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sun, 28 Jul 2019 20:50:31 +0200 Subject: [PATCH] consistently use NULL for null pointers makes the code noisier, but also somewhat more expressive. --- src/common.h | 4 +- src/config.c | 28 ++++++------- src/drv_imap.c | 94 ++++++++++++++++++++++---------------------- src/drv_maildir.c | 72 ++++++++++++++++----------------- src/drv_proxy_gen.pl | 2 +- src/main.c | 32 +++++++-------- src/mdconvert.c | 12 +++--- src/socket.c | 34 ++++++++-------- src/socket.h | 2 +- src/sync.c | 10 ++--- src/util.c | 12 +++--- 11 files changed, 151 insertions(+), 151 deletions(-) diff --git a/src/common.h b/src/common.h index 548567f..c834cb1 100644 --- a/src/common.h +++ b/src/common.h @@ -191,7 +191,7 @@ int map_name( const char *arg, char **result, uint reserve, const char *in, cons } #define ARRAY_INIT(arr) \ - do { (arr)->array.data = 0; (arr)->array.size = (arr)->alloc = 0; } while (0) + do { (arr)->array.data = NULL; (arr)->array.size = (arr)->alloc = 0; } while (0) #define ARRAY_SQUEEZE(arr) \ do { \ @@ -245,7 +245,7 @@ typedef struct { void init_wakeup( wakeup_t *tmr, void (*cb)( void * ), void *aux ); void conf_wakeup( wakeup_t *tmr, int timeout ); void wipe_wakeup( wakeup_t *tmr ); -static INLINE int ATTR_UNUSED pending_wakeup( wakeup_t *tmr ) { return tmr->links.next != 0; } +static INLINE int ATTR_UNUSED pending_wakeup( wakeup_t *tmr ) { return tmr->links.next != NULL; } void main_loop( void ); diff --git a/src/config.c b/src/config.c index 8cb56c6..5ba3724 100644 --- a/src/config.c +++ b/src/config.c @@ -54,7 +54,7 @@ get_arg( conffile_t *cfile, int required, int *comment ) error( "%s:%d: parameter missing\n", cfile->file, cfile->line ); cfile->err = 1; } - ret = 0; + ret = NULL; } else { for (escaped = 0, quoted = 0, ret = t = p; c; c = *p) { p++; @@ -74,12 +74,12 @@ get_arg( conffile_t *cfile, int required, int *comment ) if (escaped) { error( "%s:%d: unterminated escape sequence\n", cfile->file, cfile->line ); cfile->err = 1; - ret = 0; + ret = NULL; } if (quoted) { error( "%s:%d: missing closing quote\n", cfile->file, cfile->line ); cfile->err = 1; - ret = 0; + ret = NULL; } } cfile->rest = p; @@ -196,7 +196,7 @@ getopt_helper( conffile_t *cfile, int *cops, channel_conf_t *conf ) cfile->file, cfile->line, arg ); cfile->err = 1; } - while ((arg = get_arg( cfile, ARG_OPTIONAL, 0 ))); + while ((arg = get_arg( cfile, ARG_OPTIONAL, NULL ))); conf->ops[M] |= XOP_HAVE_TYPE; } else if (!strcasecmp( "SyncState", cfile->cmd )) conf->sync_state = expand_strdup( cfile->val ); @@ -223,7 +223,7 @@ getopt_helper( conffile_t *cfile, int *cops, channel_conf_t *conf ) cfile->file, cfile->line, boxOps[i].name, arg ); cfile->err = 1; } - } while ((arg = get_arg( cfile, ARG_OPTIONAL, 0 ))); + } while ((arg = get_arg( cfile, ARG_OPTIONAL, NULL ))); conf->ops[M] |= op * (XOP_HAVE_EXPUNGE / OP_EXPUNGE); return 1; } @@ -239,7 +239,7 @@ getcline( conffile_t *cfile ) char *arg; int comment; - if (cfile->rest && (arg = get_arg( cfile, ARG_OPTIONAL, 0 ))) { + if (cfile->rest && (arg = get_arg( cfile, ARG_OPTIONAL, NULL ))) { error( "%s:%d: excess token '%s'\n", cfile->file, cfile->line, arg ); cfile->err = 1; } @@ -251,7 +251,7 @@ getcline( conffile_t *cfile ) continue; return 1; } - if (!(cfile->val = get_arg( cfile, ARG_REQUIRED, 0 ))) + if (!(cfile->val = get_arg( cfile, ARG_REQUIRED, NULL ))) continue; return 1; } @@ -343,7 +343,7 @@ load_config( const char *where, int pseudo ) cfile.bufl = sizeof(buf) - 1; cfile.line = 0; cfile.err = 0; - cfile.rest = 0; + cfile.rest = NULL; gcops = 0; global_conf.expire_unread = -1; @@ -360,7 +360,7 @@ load_config( const char *where, int pseudo ) store->flat_delim = ""; *storeapp = store; storeapp = &store->next; - *storeapp = 0; + *storeapp = NULL; } goto reloop; } @@ -382,7 +382,7 @@ load_config( const char *where, int pseudo ) arg = cfile.val; do add_string_list( &channel->patterns, arg ); - while ((arg = get_arg( &cfile, ARG_OPTIONAL, 0 ))); + while ((arg = get_arg( &cfile, ARG_OPTIONAL, NULL ))); } else if (!strcasecmp( "Master", cfile.cmd )) { ms = M; @@ -438,17 +438,17 @@ load_config( const char *where, int pseudo ) group->name = nfstrdup( cfile.val ); *groupapp = group; groupapp = &group->next; - *groupapp = 0; + *groupapp = NULL; chanlistapp = &group->channels; - *chanlistapp = 0; - while ((arg = get_arg( &cfile, ARG_OPTIONAL, 0 ))) { + *chanlistapp = NULL; + while ((arg = get_arg( &cfile, ARG_OPTIONAL, NULL ))) { addone: len = strlen( arg ); chanlist = nfmalloc( sizeof(*chanlist) + len ); memcpy( chanlist->string, arg, len + 1 ); *chanlistapp = chanlist; chanlistapp = &chanlist->next; - *chanlistapp = 0; + *chanlistapp = NULL; } while (getcline( &cfile )) { if (!cfile.cmd) diff --git a/src/drv_imap.c b/src/drv_imap.c index e7ab7a0..e33b588 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -336,7 +336,7 @@ DIAG_POP iov[1].buf = cmd->param.data; iov[1].len = cmd->param.data_len; iov[1].takeOwn = GiveOwn; - cmd->param.data = 0; + cmd->param.data = NULL; ctx->buffer_mem -= cmd->param.data_len; iov[2].buf = "\r\n"; iov[2].len = 2; @@ -346,7 +346,7 @@ DIAG_POP socket_write( &ctx->conn, iov, iovcnt ); if (cmd->param.to_trash && ctx->trashnc == TrashUnknown) ctx->trashnc = TrashChecking; - cmd->next = 0; + cmd->next = NULL; *ctx->in_progress_append = cmd; ctx->in_progress_append = &cmd->next; ctx->num_in_progress++; @@ -435,7 +435,7 @@ submit_imap_cmd( imap_store_t *ctx, imap_cmd_t *cmd ) cmd->next = ctx->pending; ctx->pending = cmd; } else { - cmd->next = 0; + cmd->next = NULL; *ctx->pending_append = cmd; ctx->pending_append = &cmd->next; } @@ -649,7 +649,7 @@ imap_strchr( const char *s, char tc ) if (c == '\\') c = *++s; if (!c) - return 0; + return NULL; if (c == tc) return s; } @@ -664,12 +664,12 @@ next_arg( char **ps ) assert( ps ); s = *ps; if (!s) - return 0; + return NULL; while (isspace( (uchar)*s )) s++; if (!*s) { - *ps = 0; - return 0; + *ps = NULL; + return NULL; } if (*s == '"') { s++; @@ -678,8 +678,8 @@ next_arg( char **ps ) if (c == '\\') c = *s++; if (!c) { - *ps = 0; - return 0; + *ps = NULL; + return NULL; } *d++ = c; } @@ -695,7 +695,7 @@ next_arg( char **ps ) } } if (!*s) - s = 0; + s = NULL; *ps = s; return ret; @@ -772,9 +772,9 @@ parse_imap_list( imap_store_t *ctx, char **sp, parse_list_state_t *sts ) goto next; } *curp = cur = nfmalloc( sizeof(*cur) ); - cur->val = 0; /* for clean bail */ + cur->val = NULL; /* for clean bail */ curp = &cur->next; - *curp = 0; /* ditto */ + *curp = NULL; /* ditto */ if (*s == '(') { /* sublist */ if (sts->level == MAX_LIST_DEPTH) @@ -783,7 +783,7 @@ parse_imap_list( imap_store_t *ctx, char **sp, parse_list_state_t *sts ) cur->val = LIST; sts->stack[sts->level++] = curp; curp = &cur->child; - *curp = 0; /* for clean bail */ + *curp = NULL; /* for clean bail */ goto next2; } else if (ctx && *s == '{') { /* literal */ @@ -873,7 +873,7 @@ parse_list_init( parse_list_state_t *sts ) { sts->need_bytes = -1; sts->level = 1; - sts->head = 0; + sts->head = NULL; sts->stack[0] = &sts->head; } @@ -883,8 +883,8 @@ parse_list_continue( imap_store_t *ctx, char *s ) list_t *list; int resp; if ((resp = parse_imap_list( ctx, &s, &ctx->parse_list_sts )) != LIST_PARTIAL) { - list = (resp == LIST_BAD) ? 0 : ctx->parse_list_sts.head; - ctx->parse_list_sts.head = 0; + list = (resp == LIST_BAD) ? NULL : ctx->parse_list_sts.head; + ctx->parse_list_sts.head = NULL; resp = ctx->parse_list_sts.callback( ctx, list, s ); } return resp; @@ -971,7 +971,7 @@ static int parse_fetch_rsp( imap_store_t *ctx, list_t *list, char *s ATTR_UNUSED ) { list_t *tmp, *flags; - char *body = 0, *tuid = 0, *msgid = 0, *ep; + char *body = NULL, *tuid = NULL, *msgid = NULL, *ep; imap_message_t *cur; msg_data_t *msgdata; imap_cmd_t *cmdp; @@ -1034,7 +1034,7 @@ parse_fetch_rsp( imap_store_t *ctx, list_t *list, char *s ATTR_UNUSED ) tmp = tmp->next; if (is_atom( tmp )) { body = tmp->val; - tmp->val = 0; /* don't free together with list */ + tmp->val = NULL; /* don't free together with list */ size = tmp->len; } else error( "IMAP error: unable to parse BODY[]\n" ); @@ -1117,12 +1117,12 @@ parse_fetch_rsp( imap_store_t *ctx, list_t *list, char *s ATTR_UNUSED ) cur = nfcalloc( sizeof(*cur) ); *ctx->msgapp = &cur->gen; ctx->msgapp = &cur->gen.next; - cur->gen.next = 0; + cur->gen.next = NULL; cur->gen.uid = uid; cur->gen.flags = mask; cur->gen.status = status; cur->gen.size = size; - cur->gen.srec = 0; + cur->gen.srec = NULL; cur->gen.msgid = msgid; if (tuid) memcpy( cur->gen.tuid, tuid, TUIDL ); @@ -1141,7 +1141,7 @@ parse_capability( imap_store_t *ctx, char *cmd ) uint i; free_string_list( ctx->auth_mechs ); - ctx->auth_mechs = 0; + ctx->auth_mechs = NULL; ctx->caps = 0x80000000; while ((arg = next_arg( &cmd ))) { if (starts_with( arg, -1, "AUTH=", 5 )) { @@ -1393,7 +1393,7 @@ imap_socket_read( void *aux ) for (;;) { if (ctx->parse_list_sts.level) { - resp = parse_list_continue( ctx, 0 ); + resp = parse_list_continue( ctx, NULL ); listret: if (resp == LIST_PARTIAL) return; @@ -1427,7 +1427,7 @@ imap_socket_read( void *aux ) } if (ctx->greeting == GreetingPending && !strcmp( "PREAUTH", arg )) { - parse_response_code( ctx, 0, cmd ); + parse_response_code( ctx, NULL, cmd ); ctx->greeting = GreetingPreauth; dogreet: imap_ref( ctx ); @@ -1435,7 +1435,7 @@ imap_socket_read( void *aux ) if (imap_deref( ctx )) return; } else if (!strcmp( "OK", arg )) { - parse_response_code( ctx, 0, cmd ); + parse_response_code( ctx, NULL, cmd ); if (ctx->greeting == GreetingPending) { ctx->greeting = GreetingOk; goto dogreet; @@ -1499,7 +1499,7 @@ imap_socket_read( void *aux ) iov[0].buf = cmdp->param.data; iov[0].len = cmdp->param.data_len; iov[0].takeOwn = GiveOwn; - cmdp->param.data = 0; + cmdp->param.data = NULL; ctx->buffer_mem -= cmdp->param.data_len; iov[1].buf = "\r\n"; iov[1].len = 2; @@ -1667,7 +1667,7 @@ imap_free_store( store_t *gctx ) imap_store_t *ctx = (imap_store_t *)gctx; free_generic_messages( ctx->msgs ); - ctx->msgs = 0; + ctx->msgs = NULL; imap_set_bad_callback( gctx, imap_cancel_unowned, gctx ); gctx->next = unowned; unowned = gctx; @@ -1687,7 +1687,7 @@ imap_cleanup( void ) imap_set_bad_callback( ctx, (void (*)(void *))imap_cancel_store, ctx ); if (((imap_store_t *)ctx)->state != SST_BAD) { ((imap_store_t *)ctx)->expectBYE = 1; - imap_exec( (imap_store_t *)ctx, 0, imap_cleanup_p2, "LOGOUT" ); + imap_exec( (imap_store_t *)ctx, NULL, imap_cleanup_p2, "LOGOUT" ); } else { imap_cancel_store( ctx ); } @@ -1832,7 +1832,7 @@ imap_open_store_greeted( imap_store_t *ctx ) { socket_expect_activity( &ctx->conn, 0 ); if (!ctx->caps) - imap_exec( ctx, 0, imap_open_store_p2, "CAPABILITY" ); + imap_exec( ctx, NULL, imap_open_store_p2, "CAPABILITY" ); else imap_open_store_authenticate( ctx ); } @@ -1858,7 +1858,7 @@ imap_open_store_authenticate( imap_store_t *ctx ) #ifdef HAVE_LIBSSL if (srvc->ssl_type == SSL_STARTTLS) { if (CAP(STARTTLS)) { - imap_exec( ctx, 0, imap_open_store_authenticate_p2, "STARTTLS" ); + imap_exec( ctx, NULL, imap_open_store_authenticate_p2, "STARTTLS" ); return; } else { error( "IMAP error: SSL support not available\n" ); @@ -1898,7 +1898,7 @@ imap_open_store_tlsstarted2( int ok, void *aux ) if (!ok) imap_open_store_ssl_bail( ctx ); else - imap_exec( ctx, 0, imap_open_store_authenticate_p3, "CAPABILITY" ); + imap_exec( ctx, NULL, imap_open_store_authenticate_p3, "CAPABILITY" ); } static void @@ -1916,7 +1916,7 @@ ensure_user( imap_server_conf_t *srvc ) { if (!srvc->user) { error( "Skipping account %s, no user\n", srvc->name ); - return 0; + return NULL; } return srvc->user; } @@ -1938,7 +1938,7 @@ ensure_password( imap_server_conf_t *srvc ) if (!(fp = popen( cmd, "r" ))) { pipeerr: sys_error( "Skipping account %s, password command failed", srvc->name ); - return 0; + return NULL; } if (!fgets( buffer, sizeof(buffer), fp )) buffer[0] = 0; @@ -1949,11 +1949,11 @@ ensure_password( imap_server_conf_t *srvc ) error( "Skipping account %s, password command crashed\n", srvc->name ); else error( "Skipping account %s, password command exited with status %d\n", srvc->name, WEXITSTATUS( ret ) ); - return 0; + return NULL; } if (!buffer[0]) { error( "Skipping account %s, password command produced no output\n", srvc->name ); - return 0; + return NULL; } buffer[strcspn( buffer, "\n" )] = 0; /* Strip trailing newline */ free( srvc->pass ); /* From previous runs */ @@ -1970,7 +1970,7 @@ ensure_password( imap_server_conf_t *srvc ) } if (!*pass) { error( "Skipping account %s, no password\n", srvc->name ); - return 0; + return NULL; } /* getpass() returns a pointer to a static buffer. Make a copy for long term storage. */ srvc->pass = nfstrdup( pass ); @@ -2254,7 +2254,7 @@ imap_open_store_authenticate2( imap_store_t *ctx ) if (!ctx->conn.ssl) #endif warn( "*** IMAP Warning *** Password is being sent in the clear\n" ); - imap_exec( ctx, 0, imap_open_store_authenticate2_p2, + imap_exec( ctx, NULL, imap_open_store_authenticate2_p2, "LOGIN \"%\\s\" \"%\\s\"", srvc->user, srvc->pass ); return; } @@ -2284,7 +2284,7 @@ imap_open_store_compress( imap_store_t *ctx ) { #ifdef HAVE_LIBZ if (CAP(COMPRESS_DEFLATE)) { - imap_exec( ctx, 0, imap_open_store_compress_p2, "COMPRESS DEFLATE" ); + imap_exec( ctx, NULL, imap_open_store_compress_p2, "COMPRESS DEFLATE" ); return; } #endif @@ -2316,7 +2316,7 @@ imap_open_store_namespace( imap_store_t *ctx ) if (((!ctx->prefix && cfg->use_namespace) || !cfg->delimiter) && CAP(NAMESPACE)) { /* get NAMESPACE info */ if (!ctx->got_namespace) - imap_exec( ctx, 0, imap_open_store_namespace_p2, "NAMESPACE" ); + imap_exec( ctx, NULL, imap_open_store_namespace_p2, "NAMESPACE" ); else imap_open_store_namespace2( ctx ); return; @@ -2390,7 +2390,7 @@ imap_select_box( store_t *gctx, const char *name ) imap_store_t *ctx = (imap_store_t *)gctx; free_generic_messages( ctx->msgs ); - ctx->msgs = 0; + ctx->msgs = NULL; ctx->msgapp = &ctx->msgs; ctx->name = name; @@ -2400,7 +2400,7 @@ imap_select_box( store_t *gctx, const char *name ) static const char * imap_get_box_path( store_t *gctx ATTR_UNUSED ) { - return 0; + return NULL; } typedef struct { @@ -2623,7 +2623,7 @@ imap_load_box( store_t *gctx, uint minuid, uint maxuid, uint newuid, uint seenui if (!ctx->total_msgs) { free( excs.data ); - cb( DRV_OK, 0, 0, 0, aux ); + cb( DRV_OK, NULL, 0, 0, aux ); } else { INIT_REFCOUNTED_STATE(imap_load_box_state_t, sts, cb, aux) for (uint i = 0; i < excs.size; ) { @@ -2751,7 +2751,7 @@ imap_fetch_msg( store_t *ctx, message_t *msg, msg_data_t *data, INIT_IMAP_CMD_X(imap_cmd_fetch_msg_t, cmd, cb, aux) cmd->gen.gen.param.uid = msg->uid; cmd->msg_data = data; - data->data = 0; + data->data = NULL; imap_exec( (imap_store_t *)ctx, &cmd->gen.gen, imap_fetch_msg_p2, "UID FETCH %u (%s%sBODY.PEEK[])", msg->uid, !(msg->status & M_FLAGS) ? "FLAGS " : "", @@ -3208,8 +3208,8 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep ) server->name = nfstrdup( cfg->val ); *serverapp = server; serverapp = &server->next; - store = 0; - *storep = 0; + store = NULL; + *storep = NULL; } else if (!strcasecmp( "IMAPStore", cfg->cmd )) { store = nfcalloc( sizeof(*store) ); store->gen.driver = &imap_driver; @@ -3283,7 +3283,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep ) error( "%s:%d: Unrecognized IMAP extension '%s'\n", cfg->file, cfg->line, arg ); cfg->err = 1; gotcap: ; - } while ((arg = get_arg( cfg, ARG_OPTIONAL, 0 ))); + } while ((arg = get_arg( cfg, ARG_OPTIONAL, NULL ))); } #ifdef HAVE_LIBSSL else if (!strcasecmp( "CertificateFile", cfg->cmd )) { @@ -3343,7 +3343,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep ) error( "%s:%d: Unrecognized SSL version\n", cfg->file, cfg->line ); cfg->err = 1; } - } while ((arg = get_arg( cfg, ARG_OPTIONAL, 0 ))); + } while ((arg = get_arg( cfg, ARG_OPTIONAL, NULL ))); } else if (!strcasecmp( "RequireSSL", cfg->cmd )) require_ssl = parse_bool( cfg ); else if (!strcasecmp( "UseIMAPS", cfg->cmd )) @@ -3366,7 +3366,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep ) arg = cfg->val; do add_string_list( &server->auth_mechs, arg ); - while ((arg = get_arg( cfg, ARG_OPTIONAL, 0 ))); + while ((arg = get_arg( cfg, ARG_OPTIONAL, NULL ))); } else if (!strcasecmp( "RequireCRAM", cfg->cmd )) require_cram = parse_bool( cfg ); else if (!strcasecmp( "Tunnel", cfg->cmd )) diff --git a/src/drv_maildir.c b/src/drv_maildir.c index ec554aa..b1c9026 100644 --- a/src/drv_maildir.c +++ b/src/drv_maildir.c @@ -152,7 +152,7 @@ maildir_join_path( maildir_store_conf_t *conf, int in_inbox, const char *box ) prefix = conf->inbox; } else { if (maildir_ensure_path( conf ) < 0) - return 0; + return NULL; prefix = conf->gen.path; } pl = strlen( prefix ); @@ -161,13 +161,13 @@ maildir_join_path( maildir_store_conf_t *conf, int in_inbox, const char *box ) if (conf->sub_style == SUB_UNSET) { error( "Maildir error: accessing subfolder '%s', but store '%s' does not specify SubFolders style\n", box, conf->gen.name ); - return 0; + return NULL; } n++; } else if (c == '.' && conf->sub_style == SUB_MAILDIRPP) { error( "Maildir error: store '%s', folder '%s': SubFolders style Maildir++ does not support dots in mailbox names\n", conf->gen.name, box ); - return 0; + return NULL; } switch (conf->sub_style) { case SUB_VERBATIM: @@ -419,13 +419,13 @@ maildir_list_recurse( maildir_store_t *ctx, int isBox, int flags, pl += pathLen; if (inbox && equals( path, pl, inbox, inboxLen )) { // Inbox nested into Path. - if (maildir_list_inbox( ctx, flags, 0 ) < 0) { + if (maildir_list_inbox( ctx, flags, NULL ) < 0) { closedir( dir ); return -1; } } else if (basePath && equals( path, pl, basePath, basePathLen )) { // Path nested into Inbox. - if (maildir_list_path( ctx, flags, 0 ) < 0) { + if (maildir_list_path( ctx, flags, NULL ) < 0) { closedir( dir ); return -1; } @@ -477,7 +477,7 @@ maildir_list_inbox( maildir_store_t *ctx, int flags, const char *basePath ) add_string_list( &ctx->boxes, "INBOX" ); return maildir_list_recurse( - ctx, 1, flags, 0, 0, basePath, basePath ? strlen( basePath ) - 1 : 0, + ctx, 1, flags, NULL, 0, basePath, basePath ? strlen( basePath ) - 1 : 0, path, nfsnprintf( path, _POSIX_PATH_MAX, "%s/", ((maildir_store_conf_t *)ctx->gen.conf)->inbox ), name, nfsnprintf( name, _POSIX_PATH_MAX, "INBOX/" ) ); } @@ -494,7 +494,7 @@ maildir_list_path( maildir_store_t *ctx, int flags, const char *inbox ) if (maildir_ensure_path( (maildir_store_conf_t *)ctx->gen.conf ) < 0) return -1; return maildir_list_recurse( - ctx, 0, flags, inbox, inbox ? strlen( inbox ) : 0, 0, 0, + ctx, 0, flags, inbox, inbox ? strlen( inbox ) : 0, NULL, 0, path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", ctx->gen.conf->path ), name, 0 ); } @@ -513,7 +513,7 @@ maildir_list_store( store_t *gctx, int flags, ((flags & LIST_INBOX) && maildir_list_inbox( ctx, flags, gctx->conf->path ) < 0))) { maildir_invoke_bad_callback( ctx ); - cb( DRV_CANCELED, 0, aux ); + cb( DRV_CANCELED, NULL, aux ); } else { cb( DRV_OK, ctx->boxes, aux ); } @@ -674,7 +674,7 @@ maildir_store_uidval( maildir_store_t *ctx ) uv[1] = ctx->nuid; value.data = uv; value.size = sizeof(uv); - if ((ret = ctx->db->put( ctx->db, 0, &key, &value, 0 ))) { + if ((ret = ctx->db->put( ctx->db, NULL, &key, &value, 0 ))) { ctx->db->err( ctx->db, ret, "Maildir error: db->put()" ); return DRV_BOX_BAD; } @@ -699,13 +699,13 @@ maildir_store_uidval( maildir_store_t *ctx ) static int maildir_init_uidval( maildir_store_t *ctx ) { - ctx->uidvalidity = (uint)time( 0 ); + ctx->uidvalidity = (uint)time( NULL ); ctx->nuid = 0; ctx->uvok = 0; #ifdef USE_DB if (ctx->db) { u_int32_t count; - ctx->db->truncate( ctx->db, 0, &count, 0 ); + ctx->db->truncate( ctx->db, NULL, &count, 0 ); } #endif /* USE_DB */ return maildir_store_uidval( ctx ); @@ -749,18 +749,18 @@ maildir_uidval_lock( maildir_store_t *ctx ) sys_error( "Maildir error: cannot fstat UID database" ); return DRV_BOX_BAD; } - if (db_create( &ctx->db, 0, 0 )) { + if (db_create( &ctx->db, NULL, 0 )) { fputs( "Maildir error: db_create() failed\n", stderr ); return DRV_BOX_BAD; } - if ((ret = (ctx->db->open)( ctx->db, 0, ctx->usedb, 0, DB_HASH, + if ((ret = (ctx->db->open)( ctx->db, NULL, ctx->usedb, NULL, DB_HASH, st.st_size ? 0 : DB_CREATE | DB_TRUNCATE, 0 ))) { ctx->db->err( ctx->db, ret, "Maildir error: db->open(%s)", ctx->usedb ); return DRV_BOX_BAD; } key.data = (void *)"UIDVALIDITY"; key.size = 11; - if ((ret = ctx->db->get( ctx->db, 0, &key, &value, 0 ))) { + if ((ret = ctx->db->get( ctx->db, NULL, &key, &value, 0 ))) { if (ret != DB_NOTFOUND) { ctx->db->err( ctx->db, ret, "Maildir error: db->get()" ); return DRV_BOX_BAD; @@ -798,7 +798,7 @@ maildir_uidval_unlock( maildir_store_t *ctx ) #ifdef USE_DB if (ctx->db) { ctx->db->close( ctx->db, 0 ); - ctx->db = 0; + ctx->db = NULL; } #endif /* USE_DB */ lck.l_type = F_UNLCK; @@ -835,7 +835,7 @@ maildir_set_uid( maildir_store_t *ctx, const char *name, uint *uid ) make_key( ((maildir_store_conf_t *)ctx->gen.conf)->info_stop, &key, name ); value.data = uid; value.size = sizeof(*uid); - if ((ret = ctx->db->put( ctx->db, 0, &key, &value, 0 ))) { + if ((ret = ctx->db->put( ctx->db, NULL, &key, &value, 0 ))) { ctx->db->err( ctx->db, ret, "Maildir error: db->put()" ); return DRV_BOX_BAD; } @@ -932,11 +932,11 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist ) if (ctx->uvok || ctx->maxuid == UINT_MAX) { #ifdef USE_DB if (ctx->usedb) { - if (db_create( &tdb, 0, 0 )) { + if (db_create( &tdb, NULL, 0 )) { fputs( "Maildir error: db_create() failed\n", stderr ); return DRV_BOX_BAD; } - if ((tdb->open)( tdb, 0, 0, 0, DB_HASH, DB_CREATE, 0 )) { + if ((tdb->open)( tdb, NULL, NULL, NULL, DB_HASH, DB_CREATE, 0 )) { fputs( "Maildir error: tdb->open() failed\n", stderr ); bork: tdb->close( tdb, 0 ); @@ -946,7 +946,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist ) #endif /* USE_DB */ bl = nfsnprintf( buf, sizeof(buf) - 4, "%s/", ctx->path ); restat: - now = time( 0 ); + now = time( NULL ); for (i = 0; i < 2; i++) { memcpy( buf + bl, subdirs[i], 4 ); if (stat( buf, &st )) { @@ -987,7 +987,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist ) if (maildir_uidval_lock( ctx ) != DRV_OK) goto mbork; make_key( conf->info_stop, &key, e->d_name ); - if ((ret = ctx->db->get( ctx->db, 0, &key, &value, 0 ))) { + if ((ret = ctx->db->get( ctx->db, NULL, &key, &value, 0 ))) { if (ret != DB_NOTFOUND) { ctx->db->err( ctx->db, ret, "Maildir error: db->get()" ); mbork: @@ -998,7 +998,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist ) uid = UINT_MAX; } else { value.size = 0; - if ((ret = tdb->put( tdb, 0, &key, &value, 0 ))) { + if ((ret = tdb->put( tdb, NULL, &key, &value, 0 ))) { tdb->err( tdb, ret, "Maildir error: tdb->put()" ); goto mbork; } @@ -1016,7 +1016,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist ) continue; entry = msg_t_array_append( msglist ); entry->base = nfstrdup( e->d_name ); - entry->msgid = 0; + entry->msgid = NULL; entry->uid = uid; entry->recent = (uchar)i; entry->size = 0; @@ -1045,7 +1045,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist ) if (ctx->usedb) { if (maildir_uidval_lock( ctx ) != DRV_OK) ; - else if ((ret = ctx->db->cursor( ctx->db, 0, &dbc, 0 ))) + else if ((ret = ctx->db->cursor( ctx->db, NULL, &dbc, 0 ))) ctx->db->err( ctx->db, ret, "Maildir error: db->cursor()" ); else { for (;;) { @@ -1055,7 +1055,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist ) break; } if (!equals( key.data, (int)key.size, "UIDVALIDITY", 11 ) && - (ret = tdb->get( tdb, 0, &key, &value, 0 ))) { + (ret = tdb->get( tdb, NULL, &key, &value, 0 ))) { if (ret != DB_NOTFOUND) { tdb->err( tdb, ret, "Maildir error: tdb->get()" ); break; @@ -1217,11 +1217,11 @@ static void maildir_init_msg( maildir_store_t *ctx, maildir_message_t *msg, msg_t *entry ) { msg->base = entry->base; - entry->base = 0; /* prevent deletion */ + entry->base = NULL; /* prevent deletion */ msg->gen.msgid = entry->msgid; - entry->msgid = 0; /* prevent deletion */ + entry->msgid = NULL; /* prevent deletion */ msg->gen.size = entry->size; - msg->gen.srec = 0; + msg->gen.srec = NULL; memcpy( msg->gen.tuid, entry->tuid, TUIDL ); if (entry->recent) msg->gen.status |= M_RECENT; @@ -1251,12 +1251,12 @@ maildir_select_box( store_t *gctx, const char *name ) maildir_store_t *ctx = (maildir_store_t *)gctx; maildir_cleanup( gctx ); - ctx->msgs = 0; - ctx->excs.data = 0; + ctx->msgs = NULL; + ctx->excs.data = NULL; ctx->uvfd = -1; #ifdef USE_DB - ctx->db = 0; - ctx->usedb = 0; + ctx->db = NULL; + ctx->usedb = NULL; #endif /* USE_DB */ ctx->fresh[0] = ctx->fresh[1] = 0; if (starts_with( name, -1, "INBOX", 5 ) && (!name[5] || name[5] == '/')) { @@ -1300,7 +1300,7 @@ maildir_open_box( store_t *gctx, return; } #else - ctx->usedb = 0; + ctx->usedb = NULL; if ((ctx->uvfd = open( uvpath, O_RDWR, 0600 )) < 0) { nfsnprintf( uvpath, sizeof(uvpath), "%s/.isyncuidmap.db", ctx->path ); if ((ctx->uvfd = open( uvpath, O_RDWR, 0600 )) < 0) { @@ -1451,7 +1451,7 @@ maildir_load_box( store_t *gctx, uint minuid, uint maxuid, uint newuid, uint see ctx->excs = excs; if (maildir_scan( ctx, &msglist ) != DRV_OK) { - cb( DRV_BOX_BAD, 0, 0, 0, aux ); + cb( DRV_BOX_BAD, NULL, 0, 0, aux ); return; } msgapp = &ctx->msgs; @@ -1592,7 +1592,7 @@ maildir_store_msg( store_t *gctx, msg_data_t *data, int to_trash, uint uid; char buf[_POSIX_PATH_MAX], nbuf[_POSIX_PATH_MAX], fbuf[NUM_FLAGS + 3], base[128]; - bl = nfsnprintf( base, sizeof(base), "%lld.%d_%d.%s", (long long)time( 0 ), Pid, ++MaildirCount, Hostname ); + bl = nfsnprintf( base, sizeof(base), "%lld.%d_%d.%s", (long long)time( NULL ), Pid, ++MaildirCount, Hostname ); if (!to_trash) { #ifdef USE_DB if (ctx->usedb) { @@ -1744,7 +1744,7 @@ maildir_purge_msg( maildir_store_t *ctx, const char *name ) if ((ret = maildir_uidval_lock( ctx )) != DRV_OK) return ret; make_key( ((maildir_store_conf_t *)ctx->gen.conf)->info_stop, &key, name ); - if ((ret = ctx->db->del( ctx->db, 0, &key, 0 ))) { + if ((ret = ctx->db->del( ctx->db, NULL, &key, 0 ))) { ctx->db->err( ctx->db, ret, "Maildir error: db->del()" ); return DRV_BOX_BAD; } @@ -1767,7 +1767,7 @@ maildir_trash_msg( store_t *gctx, message_t *gmsg, nfsnprintf( buf, sizeof(buf), "%s/%s/%s", ctx->path, subdirs[gmsg->status & M_RECENT], msg->base ); s = strstr( msg->base, ((maildir_store_conf_t *)gctx->conf)->info_prefix ); nfsnprintf( nbuf, sizeof(nbuf), "%s/%s/%lld.%d_%d.%s%s", ctx->trash, - subdirs[gmsg->status & M_RECENT], (long long)time( 0 ), Pid, ++MaildirCount, Hostname, s ? s : "" ); + subdirs[gmsg->status & M_RECENT], (long long)time( NULL ), Pid, ++MaildirCount, Hostname, s ? s : "" ); if (!rename( buf, nbuf )) break; if (!stat( buf, &st )) { diff --git a/src/drv_proxy_gen.pl b/src/drv_proxy_gen.pl index c7119a6..70313cf 100755 --- a/src/drv_proxy_gen.pl +++ b/src/drv_proxy_gen.pl @@ -128,7 +128,7 @@ for (@ptypes) { /^([\w* ]+)\(\*(\w+)\)\( (.*) \)$/ or die("Cannot parse prototype '$_'\n"); my ($cmd_type, $cmd_name, $cmd_args) = ($1, $2, $3); if (defined($excluded{$cmd_name})) { - push @cmd_table, "0"; + push @cmd_table, "NULL"; next; } push @cmd_table, "proxy_$cmd_name"; diff --git a/src/main.c b/src/main.c index 3e10ec5..b35de25 100644 --- a/src/main.c +++ b/src/main.c @@ -175,7 +175,7 @@ crashHandler( int n ) close( pip[1] ); close( pip[0] ); #endif - waitpid( dpid, 0, 0 ); + waitpid( dpid, NULL, 0 ); break; } exit( 3 ); @@ -262,7 +262,7 @@ static char ** filter_boxes( string_list_t *boxes, const char *prefix, string_list_t *patterns ) { string_list_t *cpat; - char **boxarr = 0; + char **boxarr = NULL; const char *ps; uint not, fnot, pfxl, num = 0, rnum = 0; @@ -287,7 +287,7 @@ filter_boxes( string_list_t *boxes, const char *prefix, string_list_t *patterns if (num + 1 >= rnum) boxarr = nfrealloc( boxarr, (rnum = (rnum + 10) * 2) * sizeof(*boxarr) ); boxarr[num++] = nfstrdup( boxes->string + pfxl ); - boxarr[num] = 0; + boxarr[num] = NULL; } } qsort( boxarr, num, sizeof(*boxarr), cmp_box_names ); @@ -348,7 +348,7 @@ add_named_channel( chan_ent_t ***chanapp, char *channame, int ops[] ) { channel_conf_t *chan; chan_ent_t *ce; - box_ent_t *boxes = 0, **mboxapp = &boxes, *mbox; + box_ent_t *boxes = NULL, **mboxapp = &boxes, *mbox; char *boxp, *nboxp; size_t boxl; char boxlist = 0; @@ -359,12 +359,12 @@ add_named_channel( chan_ent_t ***chanapp, char *channame, int ops[] ) if (!strcmp( chan->name, channame )) goto gotchan; error( "No channel or group named '%s' defined.\n", channame ); - return 0; + return NULL; gotchan: if (boxp) { if (!chan->patterns) { error( "Cannot override mailbox in channel '%s' - no Patterns.\n", channame ); - return 0; + return NULL; } boxlist = 1; do { @@ -381,7 +381,7 @@ add_named_channel( chan_ent_t ***chanapp, char *channame, int ops[] ) else mbox->name = nfstrndup( "INBOX", 5 ); mbox->present[M] = mbox->present[S] = BOX_POSSIBLE; - mbox->next = 0; + mbox->next = NULL; *mboxapp = mbox; mboxapp = &mbox->next; boxes_total++; @@ -426,11 +426,11 @@ int main( int argc, char **argv ) { main_vars_t mvars[1]; - chan_ent_t *chans = 0, **chanapp = &chans; + chan_ent_t *chans = NULL, **chanapp = &chans; group_conf_t *group; channel_conf_t *chan; string_list_t *channame; - char *config = 0, *opt, *ochar; + char *config = NULL, *opt, *ochar; int oind, cops = 0, op, ops[2] = { 0, 0 }, pseudo = 0; tzset(); @@ -447,7 +447,7 @@ main( int argc, char **argv ) memset( mvars, 0, sizeof(*mvars) ); mvars->t[1] = 1; - for (oind = 1, ochar = 0; ; ) { + for (oind = 1, ochar = NULL; ; ) { if (!ochar || !*ochar) { if (oind >= argc) break; @@ -846,7 +846,7 @@ sync_chans( main_vars_t *mvars, int ent ) if (mvars->skip) goto next2; mvars->state[M] = mvars->state[S] = ST_FRESH; - if ((DFlags & DEBUG_DRV) || (mvars->chan->stores[M]->driver->get_caps( 0 ) & mvars->chan->stores[S]->driver->get_caps( 0 ) & DRV_VERBOSE)) + if ((DFlags & DEBUG_DRV) || (mvars->chan->stores[M]->driver->get_caps( NULL ) & mvars->chan->stores[S]->driver->get_caps( NULL ) & DRV_VERBOSE)) labels[M] = "M: ", labels[S] = "S: "; else labels[M] = labels[S] = ""; @@ -881,8 +881,8 @@ sync_chans( main_vars_t *mvars, int ent ) boxes[S] = filter_boxes( mvars->boxes[S], mvars->chan->boxes[S], mvars->chan->patterns ); mboxapp = &mvars->chanptr->boxes; for (mb = sb = 0; ; ) { - char *mname = boxes[M] ? boxes[M][mb] : 0; - char *sname = boxes[S] ? boxes[S][sb] : 0; + char *mname = boxes[M] ? boxes[M][mb] : NULL; + char *sname = boxes[S] ? boxes[S][sb] : NULL; if (!mname && !sname) break; mbox = nfmalloc( sizeof(*mbox) ); @@ -903,7 +903,7 @@ sync_chans( main_vars_t *mvars, int ent ) mbox->present[S] = BOX_PRESENT; sb++; } - mbox->next = 0; + mbox->next = NULL; *mboxapp = mbox; mboxapp = &mbox->next; boxes_total++; @@ -945,7 +945,7 @@ sync_chans( main_vars_t *mvars, int ent ) mvars->cben = 0; for (t = 0; t < 2; t++) { free_string_list( mvars->boxes[t] ); - mvars->boxes[t] = 0; + mvars->boxes[t] = NULL; if (mvars->state[t] == ST_FRESH) { /* An unconnected store may be only cancelled. */ mvars->state[t] = ST_CLOSED; @@ -966,7 +966,7 @@ sync_chans( main_vars_t *mvars, int ent ) free( mbox->name ); free( mbox ); } - mvars->chanptr->boxes = 0; + mvars->chanptr->boxes = NULL; mvars->chanptr->boxlist = 0; } next2: diff --git a/src/mdconvert.c b/src/mdconvert.c index ec2a558..b33844c 100644 --- a/src/mdconvert.c +++ b/src/mdconvert.c @@ -117,11 +117,11 @@ convert( const char *box, int altmap ) sys_error( "Cannot create %s", tdpath ); goto sbork; } - if (db_create( &db, 0, 0 )) { + if (db_create( &db, NULL, 0 )) { fputs( "Error: db_create() failed\n", stderr ); goto tbork; } - if ((ret = (db->open)( db, 0, dbpath, 0, DB_HASH, altmap ? DB_CREATE|DB_TRUNCATE : 0, 0 ))) { + if ((ret = (db->open)( db, NULL, dbpath, NULL, DB_HASH, altmap ? DB_CREATE|DB_TRUNCATE : 0, 0 ))) { db->err( db, ret, "Error: db->open(%s)", dbpath ); dbork: db->close( db, 0 ); @@ -143,12 +143,12 @@ convert( const char *box, int altmap ) } value.data = uv; value.size = sizeof(uv); - if ((ret = db->put( db, 0, &key, &value, 0 ))) { + if ((ret = db->put( db, NULL, &key, &value, 0 ))) { db->err( db, ret, "Error: cannot write UIDVALIDITY for '%s'", box ); goto dbork; } } else { - if ((ret = db->get( db, 0, &key, &value, 0 ))) { + if ((ret = db->get( db, NULL, &key, &value, 0 ))) { db->err( db, ret, "Error: cannot read UIDVALIDITY of '%s'", box ); goto dbork; } @@ -188,7 +188,7 @@ convert( const char *box, int altmap ) uid = atoi( p + 3 ); value.data = &uid; value.size = sizeof(uid); - if ((ret = db->put( db, 0, &key, &value, 0 ))) { + if ((ret = db->put( db, NULL, &key, &value, 0 ))) { db->err( db, ret, "Error: cannot write UID for '%s'", box ); goto ebork; } @@ -197,7 +197,7 @@ convert( const char *box, int altmap ) s = strpbrk( e->d_name, ",:" ); key.data = e->d_name; key.size = s ? (size_t)(s - e->d_name) : strlen( e->d_name ); - if ((ret = db->get( db, 0, &key, &value, 0 ))) { + if ((ret = db->get( db, NULL, &key, &value, 0 ))) { if (ret != DB_NOTFOUND) { db->err( db, ret, "Error: cannot read UID for '%s'", box ); goto ebork; diff --git a/src/socket.c b/src/socket.c index c792097..b7b6fc2 100644 --- a/src/socket.c +++ b/src/socket.c @@ -74,7 +74,7 @@ print_ssl_errors( const char *fmt, ... ) nfvasprintf( &action, fmt, va ); va_end( va ); while ((err = ERR_get_error())) - error( "Error while %s: %s\n", action, ERR_error_string( err, 0 ) ); + error( "Error while %s: %s\n", action, ERR_error_string( err, NULL ) ); free( action ); } @@ -85,7 +85,7 @@ print_ssl_socket_errors( const char *func, conn_t *conn ) int num = 0; while ((err = ERR_get_error())) { - error( "Socket error: secure %s %s: %s\n", func, conn->name, ERR_error_string( err, 0 ) ); + error( "Socket error: secure %s %s: %s\n", func, conn->name, ERR_error_string( err, NULL ) ); num++; } return num; @@ -273,7 +273,7 @@ DIAG_POP return 0; } - if (conf->cert_file && !SSL_CTX_load_verify_locations( mconf->SSLContext, conf->cert_file, 0 )) { + if (conf->cert_file && !SSL_CTX_load_verify_locations( mconf->SSLContext, conf->cert_file, NULL )) { print_ssl_errors( "loading certificate file '%s'", conf->cert_file ); return 0; } @@ -281,7 +281,7 @@ DIAG_POP if (mconf->system_certs && !SSL_CTX_set_default_verify_paths( mconf->SSLContext )) { ulong err; while ((err = ERR_get_error())) - warn( "Warning: Unable to load default certificate files: %s\n", ERR_error_string( err, 0 ) ); + warn( "Warning: Unable to load default certificate files: %s\n", ERR_error_string( err, NULL ) ); } SSL_CTX_set_verify( mconf->SSLContext, SSL_VERIFY_NONE, NULL ); @@ -602,7 +602,7 @@ socket_connect_next( conn_t *conn ) { sys_error( "Cannot connect to %s", conn->name ); free( conn->name ); - conn->name = 0; + conn->name = NULL; conn->curr_addr = conn->curr_addr->ai_next; socket_connect_one( conn ); } @@ -619,7 +619,7 @@ socket_connected( conn_t *conn ) { if (conn->addrs) { freeaddrinfo( conn->addrs ); - conn->addrs = 0; + conn->addrs = NULL; } conf_notifier( &conn->notify, 0, POLLIN ); socket_expect_activity( conn, 0 ); @@ -632,10 +632,10 @@ socket_cleanup_names( conn_t *conn ) { if (conn->addrs) { freeaddrinfo( conn->addrs ); - conn->addrs = 0; + conn->addrs = NULL; } free( conn->name ); - conn->name = 0; + conn->name = NULL; } static void @@ -656,7 +656,7 @@ socket_close( conn_t *sock ) #ifdef HAVE_LIBSSL if (sock->ssl) { SSL_free( sock->ssl ); - sock->ssl = 0; + sock->ssl = NULL; wipe_wakeup( &sock->ssl_fake ); } #endif @@ -664,17 +664,17 @@ socket_close( conn_t *sock ) if (sock->in_z) { inflateEnd( sock->in_z ); free( sock->in_z ); - sock->in_z = 0; + sock->in_z = NULL; deflateEnd( sock->out_z ); free( sock->out_z ); - sock->out_z = 0; + sock->out_z = NULL; wipe_wakeup( &sock->z_fake ); } #endif while (sock->write_buf) dispose_chunk( sock ); free( sock->append_buf ); - sock->append_buf = 0; + sock->append_buf = NULL; } static int @@ -822,7 +822,7 @@ socket_read_line( conn_t *b ) } if (b->state == SCK_EOF) return (void *)~0; - return 0; + return NULL; } n = (uint)(p + 1 - s); b->offset += n; @@ -902,7 +902,7 @@ do_queued_write( conn_t *conn ) static void do_append( conn_t *conn, buff_chunk_t *bc ) { - bc->next = 0; + bc->next = NULL; conn->buffer_mem += bc->len; *conn->write_buf_append = bc; conn->write_buf_append = &bc->next; @@ -942,7 +942,7 @@ do_flush( conn_t *conn ) bc->len = (uint)((char *)conn->out_z->next_out - bc->data); if (bc->len) { do_append( conn, bc ); - bc = 0; + bc = NULL; buf_avail = 0; } else { buf_avail = conn->out_z->avail_out; @@ -955,7 +955,7 @@ do_flush( conn_t *conn ) #endif if (bc) { do_append( conn, bc ); - conn->append_buf = 0; + conn->append_buf = NULL; #ifdef HAVE_LIBZ conn->append_avail = 0; #endif @@ -1033,7 +1033,7 @@ socket_write( conn_t *conn, conn_iovec_t *iov, int iovcnt ) } if (!buf_avail) { do_append( conn, bc ); - bc = 0; + bc = NULL; break; } } diff --git a/src/socket.h b/src/socket.h index 4113770..bcc7fe1 100644 --- a/src/socket.h +++ b/src/socket.h @@ -134,7 +134,7 @@ static INLINE void socket_init( conn_t *conn, conn->write_callback = write_callback; conn->callback_aux = aux; conn->fd = -1; - conn->name = 0; + conn->name = NULL; conn->write_buf_append = &conn->write_buf; } void socket_connect( conn_t *conn, void (*cb)( int ok, void *aux ) ); diff --git a/src/sync.c b/src/sync.c index a1fbcf8..5243b23 100644 --- a/src/sync.c +++ b/src/sync.c @@ -237,7 +237,7 @@ static void match_tuids( sync_vars_t *svars, int t, message_t *msgs ) { sync_rec_t *srec; - message_t *tmsg, *ntmsg = 0; + message_t *tmsg, *ntmsg = NULL; const char *diag; int num_lost = 0; @@ -870,7 +870,7 @@ load_state( sync_vars_t *svars ) "(got %s, expected " JOURNAL_VERSION ")\n", buf ); goto jbail; } - srec = 0; + srec = NULL; line = 1; while (fgets( buf, sizeof(buf), jfp )) { line++; @@ -1330,7 +1330,7 @@ box_opened2( sync_vars_t *svars, int t ) sync_ref( svars ); load_box( svars, M, minwuid, mexcs.array ); if (!check_cancel( svars )) - load_box( svars, S, (svars->opts[S] & OPEN_OLD) ? 1 : UINT_MAX, (uint_array_t){ 0, 0 } ); + load_box( svars, S, (svars->opts[S] & OPEN_OLD) ? 1 : UINT_MAX, (uint_array_t){ NULL, 0 } ); sync_deref( svars ); } @@ -1748,7 +1748,7 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux // but some are still propagated because they are important, we need to // ensure explicitly that the bulk fetch limit is upped. svars->mmaxxuid = srec->uid[M]; - srec->msg[M]->srec = 0; + srec->msg[M]->srec = NULL; srec->status = S_DEAD; } } @@ -2063,7 +2063,7 @@ msgs_flags_set( sync_vars_t *svars, int t ) cv = nfmalloc( sizeof(*cv) ); cv->cb = msg_rtrashed; cv->aux = INV_AUX; - cv->srec = 0; + cv->srec = NULL; cv->msg = tmsg; copy_msg( cv ); if (check_cancel( svars )) diff --git a/src/util.c b/src/util.c index b9d98e4..08443de 100644 --- a/src/util.c +++ b/src/util.c @@ -455,7 +455,7 @@ expand_strdup( const char *s ) if (*s == '~') { s++; if (!*s) { - p = 0; + p = NULL; q = Home; } else if (*s == '/') { p = s; @@ -468,7 +468,7 @@ expand_strdup( const char *s ) } else pw = getpwnam( s ); if (!pw) - return 0; + return NULL; q = pw->pw_dir; } nfasprintf( &r, "%s%s", q, p ? p : "" ); @@ -656,7 +656,7 @@ list_unlink( list_head_t *head ) assert( head->prev->next == head); head->next->prev = head->prev; head->prev->next = head->next; - head->next = head->prev = 0; + head->next = head->prev = NULL; } static notifier_t *notifiers; @@ -714,7 +714,7 @@ wipe_notifier( notifier_t *sn ) for (snp = ¬ifiers; *snp != sn; snp = &(*snp)->next) assert( *snp ); *snp = sn->next; - sn->next = 0; + sn->next = NULL; changed = 1; #ifdef HAVE_SYS_POLL_H @@ -730,7 +730,7 @@ wipe_notifier( notifier_t *sn ) static time_t get_now( void ) { - return time( 0 ); + return time( NULL ); } static list_head_t timers = { &timers, &timers }; @@ -740,7 +740,7 @@ init_wakeup( wakeup_t *tmr, void (*cb)( void * ), void *aux ) { tmr->cb = cb; tmr->aux = aux; - tmr->links.next = tmr->links.prev = 0; + tmr->links.next = tmr->links.prev = NULL; } void