From dc48bee02071eb3eb2f535e203c36c528e1547a8 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 27 Aug 2018 13:31:04 -0400 Subject: [PATCH] cleaned up some compiler warnings --- citadel/modules/ctdlproto/serv_file.c | 34 ++++++++--------- citadel/modules/fulltext/serv_fulltext.c | 47 +++++++----------------- citadel/modules/sieve/serv_sieve.c | 39 ++++++++++---------- 3 files changed, 48 insertions(+), 72 deletions(-) diff --git a/citadel/modules/ctdlproto/serv_file.c b/citadel/modules/ctdlproto/serv_file.c index 936b46b8e..9af465e4d 100644 --- a/citadel/modules/ctdlproto/serv_file.c +++ b/citadel/modules/ctdlproto/serv_file.c @@ -355,8 +355,6 @@ void cmd_uimg(char *cmdbuf) */ void cmd_clos(char *cmdbuf) { - char buf[256]; - if (CC->download_fp == NULL) { cprintf("%d You don't have a download file open.\n", ERROR + RESOURCE_NOT_OPEN); return; @@ -386,43 +384,41 @@ void abort_upl(CitContext *who) */ void cmd_ucls(char *cmd) { - struct CitContext *CCC = CC; FILE *fp; - char upload_notice[512]; - static int seq = 0; + char upload_notice[SIZ]; - if (CCC->upload_fp == NULL) { + if (CC->upload_fp == NULL) { cprintf("%d You don't have an upload file open.\n", ERROR + RESOURCE_NOT_OPEN); return; } fclose(CC->upload_fp); - CCC->upload_fp = NULL; + CC->upload_fp = NULL; if (!strcasecmp(cmd, "1")) { - cprintf("%d File '%s' saved.\n", CIT_OK, CCC->upl_path); - fp = fopen(CCC->upl_filedir, "a"); + cprintf("%d File '%s' saved.\n", CIT_OK, CC->upl_path); + fp = fopen(CC->upl_filedir, "a"); if (fp == NULL) { - fp = fopen(CCC->upl_filedir, "w"); + fp = fopen(CC->upl_filedir, "w"); } if (fp != NULL) { - fprintf(fp, "%s %s %s\n", CCC->upl_file, CCC->upl_mimetype, CCC->upl_comment); + fprintf(fp, "%s %s %s\n", CC->upl_file, CC->upl_mimetype, CC->upl_comment); fclose(fp); } - if ((CCC->room.QRflags2 & QR2_NOUPLMSG) == 0) { + if ((CC->room.QRflags2 & QR2_NOUPLMSG) == 0) { /* put together an upload notice */ snprintf(upload_notice, sizeof upload_notice, "NEW UPLOAD: '%s'\n %s\n%s\n", - CCC->upl_file, - CCC->upl_comment, - CCC->upl_mimetype); - quickie_message(CCC->curr_user, NULL, NULL, CCC->room.QRname, - upload_notice, 0, NULL); + CC->upl_file, + CC->upl_comment, + CC->upl_mimetype + ); + quickie_message(CC->curr_user, NULL, NULL, CC->room.QRname, upload_notice, 0, NULL); } } else { - abort_upl(CCC); - cprintf("%d File '%s' aborted.\n", CIT_OK, CCC->upl_path); + abort_upl(CC); + cprintf("%d File '%s' aborted.\n", CIT_OK, CC->upl_path); } } diff --git a/citadel/modules/fulltext/serv_fulltext.c b/citadel/modules/fulltext/serv_fulltext.c index 4fced5e28..17c755da5 100644 --- a/citadel/modules/fulltext/serv_fulltext.c +++ b/citadel/modules/fulltext/serv_fulltext.c @@ -1,6 +1,6 @@ /* * This module handles fulltext indexing of the message base. - * Copyright (c) 2005-2017 by the citadel.org team + * Copyright (c) 2005-2018 by the citadel.org team * * This program is open source software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -80,6 +80,7 @@ int longcmp(const void *rec1, const void *rec2) { return(0); } + /* * Flush our index cache out to disk. */ @@ -204,7 +205,6 @@ void ft_index_message(long msgnum, int op) { } - /* * Add a message to the list of those to be indexed. */ @@ -214,14 +214,14 @@ void ft_index_msg(long msgnum, void *userdata) { ++ft_num_msgs; if (ft_num_msgs > ft_num_alloc) { ft_num_alloc += 1024; - ft_newmsgs = realloc(ft_newmsgs, - (ft_num_alloc * sizeof(long))); + ft_newmsgs = realloc(ft_newmsgs, (ft_num_alloc * sizeof(long))); } ft_newmsgs[ft_num_msgs - 1] = msgnum; } } + /* * Scan a room for messages to index. */ @@ -240,7 +240,6 @@ void ft_index_room(struct ctdlroom *qrbuf, void *data) */ void do_fulltext_indexing(void) { int i; - static time_t last_index = 0L; static time_t last_progress = 0L; static int is_running = 0; if (is_running) return; /* Concurrency check - only one can run */ @@ -254,32 +253,7 @@ void do_fulltext_indexing(void) { } /* - * Make sure we don't run the indexer too frequently. - * FIXME move the setting into config - time_t now = time(NULL); - if ( (now - last_index) < 300L) { - syslog(LOG_DEBUG, - "fulltext: indexing interval not yet reached; last run was %ldm%lds ago", - ((now - last_index) / 60), - ((now - last_index) % 60) - ); - return; - } - */ - - /* - * Silently return if our fulltext index is up to date with new messages. - */ - if ( - (CtdlGetConfigLong("MMfulltext") >= CtdlGetConfigLong("MMhighest")) - && (CtdlGetConfigInt("MM_fulltext_wordbreaker") == FT_WORDBREAKER_ID) - ) { - return; /* nothing to do! */ - } - - /* - * If we've switched wordbreaker modules, burn the index and start - * over. + * If we've switched wordbreaker modules, burn the index and start over. */ begin_critical_section(S_CONTROL); if (CtdlGetConfigInt("MM_fulltext_wordbreaker") != FT_WORDBREAKER_ID) { @@ -292,6 +266,13 @@ void do_fulltext_indexing(void) { } end_critical_section(S_CONTROL); + /* + * Silently return if our fulltext index is up to date with new messages. + */ + if ((CtdlGetConfigLong("MMfulltext") >= CtdlGetConfigLong("MMhighest"))) { + return; /* nothing to do! */ + } + /* * Now go through each room and find messages to index. */ @@ -354,7 +335,6 @@ void do_fulltext_indexing(void) { CtdlSetConfigLong("MMfulltext", ft_newhighest); CtdlSetConfigInt("MM_fulltext_wordbreaker", FT_WORDBREAKER_ID); end_critical_section(S_CONTROL); - last_index = time(NULL); syslog(LOG_DEBUG, "fulltext: indexing finished"); is_running = 0; @@ -362,7 +342,6 @@ void do_fulltext_indexing(void) { } - /* * API call to perform searches. * (This one does the "all of these words" search.) @@ -472,6 +451,7 @@ void cmd_srch(char *argbuf) { cprintf("000\n"); } + /* * Zero out our index cache. */ @@ -491,6 +471,7 @@ void ft_delete_remove(char *room, long msgnum) } } + /*****************************************************************************/ CTDL_MODULE_INIT(fulltext) diff --git a/citadel/modules/sieve/serv_sieve.c b/citadel/modules/sieve/serv_sieve.c index 30f64baab..30e031007 100644 --- a/citadel/modules/sieve/serv_sieve.c +++ b/citadel/modules/sieve/serv_sieve.c @@ -216,7 +216,6 @@ int ctdl_discard(sieve2_context_t *s, void *my) } - /* * Callback function to indicate that a message should be rejected */ @@ -267,7 +266,6 @@ int ctdl_reject(sieve2_context_t *s, void *my) } - /* * Callback function to indicate that a vacation message should be generated */ @@ -356,11 +354,11 @@ int ctdl_vacation(sieve2_context_t *s, void *my) } +#if 0 /* * Callback function to parse addresses per local system convention * It is disabled because we don't support subaddresses. */ -#if 0 int ctdl_getsubaddress(sieve2_context_t *s, void *my) { struct ctdl_sieve *cs = (struct ctdl_sieve *)my; @@ -418,16 +416,17 @@ int ctdl_getenvelope(sieve2_context_t *s, void *my) } +#if 0 /* * Callback function to fetch message body * (Uncomment the code if we implement this extension) * + */ int ctdl_getbody(sieve2_context_t *s, void *my) { return SIEVE2_ERROR_UNSUPPORTED; } - * - */ +#endif /* @@ -483,6 +482,7 @@ int ctdl_getscript(sieve2_context_t *s, void *my) { return SIEVE2_ERROR_GETSCRIPT; } + /* * Callback function to retrieve message headers */ @@ -496,7 +496,6 @@ int ctdl_getheaders(sieve2_context_t *s, void *my) { } - /* * Add a room to the list of those rooms which potentially require sieve processing */ @@ -515,7 +514,6 @@ void sieve_queue_room(struct ctdlroom *which_room) { } - /* * Perform sieve processing for one message (called by sieve_do_room() for each message) */ @@ -529,9 +527,8 @@ void sieve_do_msg(long msgnum, void *userdata) { size_t headers_len = 0; int len = 0; - if (u == NULL) - { - syslog(LOG_EMERG, "Can't process message <%ld> without userdata!", msgnum); + if (u == NULL) { + syslog(LOG_ERR, "Can't process message <%ld> without userdata!", msgnum); return; } @@ -646,7 +643,7 @@ void sieve_do_msg(long msgnum, void *userdata) { syslog(LOG_DEBUG, "Calling sieve2_execute()"); res = sieve2_execute(sieve2_context, &my); if (res != SIEVE2_OK) { - syslog(LOG_CRIT, "sieve2_execute() returned %d: %s", res, sieve2_errstr(res)); + syslog(LOG_ERR, "sieve2_execute() returned %d: %s", res, sieve2_errstr(res)); } free(my.rfc822headers); @@ -902,7 +899,7 @@ void sieve_do_room(char *roomname) { syslog(LOG_DEBUG, "Rules found. Performing Sieve processing for <%s>", roomname); if (CtdlGetRoom(&CC->room, roomname) != 0) { - syslog(LOG_CRIT, "ERROR: cannot load <%s>", roomname); + syslog(LOG_ERR, "ERROR: cannot load <%s>", roomname); return; } @@ -910,13 +907,13 @@ void sieve_do_room(char *roomname) { res = sieve2_alloc(&sieve2_context); if (res != SIEVE2_OK) { - syslog(LOG_CRIT, "sieve2_alloc() returned %d: %s", res, sieve2_errstr(res)); + syslog(LOG_ERR, "sieve2_alloc() returned %d: %s", res, sieve2_errstr(res)); return; } res = sieve2_callbacks(sieve2_context, ctdl_sieve_callbacks); if (res != SIEVE2_OK) { - syslog(LOG_CRIT, "sieve2_callbacks() returned %d: %s", res, sieve2_errstr(res)); + syslog(LOG_ERR, "sieve2_callbacks() returned %d: %s", res, sieve2_errstr(res)); goto BAIL; } @@ -927,7 +924,7 @@ void sieve_do_room(char *roomname) { my.u = &u; res = sieve2_validate(sieve2_context, &my); if (res != SIEVE2_OK) { - syslog(LOG_CRIT, "sieve2_validate() returned %d: %s", res, sieve2_errstr(res)); + syslog(LOG_ERR, "sieve2_validate() returned %d: %s", res, sieve2_errstr(res)); goto BAIL; } @@ -942,7 +939,7 @@ void sieve_do_room(char *roomname) { BAIL: res = sieve2_free(&sieve2_context); if (res != SIEVE2_OK) { - syslog(LOG_CRIT, "sieve2_free() returned %d: %s", res, sieve2_errstr(res)); + syslog(LOG_ERR, "sieve2_free() returned %d: %s", res, sieve2_errstr(res)); } /* Rewrite the config if we have to */ @@ -1282,13 +1279,13 @@ void ctdl_sieve_init(void) { */ res = sieve2_alloc(&sieve2_context); if (res != SIEVE2_OK) { - syslog(LOG_CRIT, "sieve2_alloc() returned %d: %s", res, sieve2_errstr(res)); + syslog(LOG_ERR, "sieve2_alloc() returned %d: %s", res, sieve2_errstr(res)); return; } res = sieve2_callbacks(sieve2_context, ctdl_sieve_callbacks); if (res != SIEVE2_OK) { - syslog(LOG_CRIT, "sieve2_callbacks() returned %d: %s", res, sieve2_errstr(res)); + syslog(LOG_ERR, "sieve2_callbacks() returned %d: %s", res, sieve2_errstr(res)); goto BAIL; } @@ -1297,11 +1294,12 @@ void ctdl_sieve_init(void) { BAIL: res = sieve2_free(&sieve2_context); if (res != SIEVE2_OK) { - syslog(LOG_CRIT, "sieve2_free() returned %d: %s", res, sieve2_errstr(res)); + syslog(LOG_ERR, "sieve2_free() returned %d: %s", res, sieve2_errstr(res)); } } + void cleanup_sieve(void) { struct RoomProcList *ptr, *ptr2; @@ -1321,6 +1319,7 @@ void cleanup_sieve(void) end_critical_section(S_SIEVELIST); } + int serv_sieve_room(struct ctdlroom *room) { if (!strcasecmp(&room->QRname[11], MAILROOM)) { @@ -1329,6 +1328,7 @@ int serv_sieve_room(struct ctdlroom *room) return 0; } + CTDL_MODULE_INIT(sieve) { if (!threading) @@ -1343,4 +1343,3 @@ CTDL_MODULE_INIT(sieve) /* return our module name for the log */ return "sieve"; } - -- 2.30.2