From 5db07229f71411b3e1449cc401ecfa54a5aecdc3 Mon Sep 17 00:00:00 2001 From: SJ Date: Sat, 3 Nov 2012 23:42:36 +0100 Subject: [PATCH] code cleanup to make gcc 4.7.1 happy --- src/Makefile.in | 2 +- src/archive.c | 12 ++++++------ src/dirs.c | 3 +-- src/imap.c | 3 +-- src/memc.c | 6 ++---- src/parser.c | 14 +++++++------- src/pileraget.c | 4 ++-- src/pilerget.c | 4 ++-- src/test.c | 4 +--- 9 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/Makefile.in b/src/Makefile.in index 91e47ef4..49429b64 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -43,7 +43,7 @@ piler: piler.c libpiler.a libpiler.a: $(OBJS) $(MYSQL_OBJS) ar cr libpiler.a $(OBJS) $(MYSQL_OBJS) ranlib libpiler.a - $(CC) -shared -Wl -o libpiler.so.$(LIBPILER_VERSION) $(OBJS) $(MYSQL_OBJS) + $(CC) -shared -o libpiler.so.$(LIBPILER_VERSION) $(OBJS) $(MYSQL_OBJS) ln -sf libpiler.so.$(LIBPILER_VERSION) libpiler.so ln -sf libpiler.so.$(LIBPILER_VERSION) libpiler.so.$(PILER_VERSION) diff --git a/src/archive.c b/src/archive.c index 5551f14f..662b0ae6 100644 --- a/src/archive.c +++ b/src/archive.c @@ -203,7 +203,7 @@ CLEANUP: int retrieve_email_from_archive(struct session_data *sdata, FILE *dest, struct __config *cfg){ - int i, rc, n, attachments; + int i, attachments; char *buffer=NULL, *saved_buffer, *p, filename[SMALLBUFSIZE], pointer[SMALLBUFSIZE]; struct ptr_array ptr_arr[MAX_ATTACHMENTS]; @@ -222,10 +222,10 @@ int retrieve_email_from_archive(struct session_data *sdata, FILE *dest, struct _ snprintf(filename, sizeof(filename)-1, "%s/%c%c/%c%c/%c%c/%s.m", cfg->queuedir, *(sdata->ttmpfile+RND_STR_LEN-6), *(sdata->ttmpfile+RND_STR_LEN-5), *(sdata->ttmpfile+RND_STR_LEN-4), *(sdata->ttmpfile+RND_STR_LEN-3), *(sdata->ttmpfile+RND_STR_LEN-2), *(sdata->ttmpfile+RND_STR_LEN-1), sdata->ttmpfile); if(attachments == 0){ - rc = retrieve_file_from_archive(filename, WRITE_TO_STDOUT, &buffer, dest, cfg); + retrieve_file_from_archive(filename, WRITE_TO_STDOUT, &buffer, dest, cfg); } else { - rc = retrieve_file_from_archive(filename, WRITE_TO_BUFFER, &buffer, dest, cfg); + retrieve_file_from_archive(filename, WRITE_TO_BUFFER, &buffer, dest, cfg); if(buffer){ saved_buffer = buffer; @@ -236,20 +236,20 @@ int retrieve_email_from_archive(struct session_data *sdata, FILE *dest, struct _ p = strstr(buffer, pointer); if(p){ *p = '\0'; - n = fwrite(buffer, 1, p - buffer, dest); + fwrite(buffer, 1, p - buffer, dest); buffer = p + strlen(pointer); if(strlen(ptr_arr[i].piler_id) == RND_STR_LEN){ snprintf(filename, sizeof(filename)-1, "%s/%c%c/%c%c/%c%c/%s.a%d", cfg->queuedir, ptr_arr[i].piler_id[RND_STR_LEN-6], ptr_arr[i].piler_id[RND_STR_LEN-5], ptr_arr[i].piler_id[RND_STR_LEN-4], ptr_arr[i].piler_id[RND_STR_LEN-3], ptr_arr[i].piler_id[RND_STR_LEN-2], ptr_arr[i].piler_id[RND_STR_LEN-1], ptr_arr[i].piler_id, ptr_arr[i].attachment_id); - rc = retrieve_file_from_archive(filename, WRITE_TO_STDOUT, NULL, dest, cfg); + retrieve_file_from_archive(filename, WRITE_TO_STDOUT, NULL, dest, cfg); } } } if(buffer){ - n = fwrite(buffer, 1, strlen(buffer), dest); + fwrite(buffer, 1, strlen(buffer), dest); } buffer = saved_buffer; diff --git a/src/dirs.c b/src/dirs.c index 19827aba..8347e71a 100644 --- a/src/dirs.c +++ b/src/dirs.c @@ -47,14 +47,13 @@ void check_and_create_directories(struct __config *cfg, uid_t uid, gid_t gid){ void createdir(char *path, uid_t uid, gid_t gid, mode_t mode){ struct stat st; - int rc; if(strlen(path) > 2){ if(path[strlen(path)-1] == '/') path[strlen(path)-1] = '\0'; if(stat(path, &st)){ if(mkdir(path, mode) == 0){ - rc = chown(path, uid, gid); + chown(path, uid, gid); syslog(LOG_PRIORITY, "created directory: *%s*", path); } else syslog(LOG_PRIORITY, "could not create directory: *%s*", path); diff --git a/src/imap.c b/src/imap.c index b017162d..02395fd3 100644 --- a/src/imap.c +++ b/src/imap.c @@ -318,7 +318,6 @@ void close_connection(int sd, struct __data *data, int use_ssl){ int list_folders(int sd, int *seq, char *folders, int foldersize, int use_ssl, struct __data *data){ - int n; char *p, *q, tag[SMALLBUFSIZE], tagok[SMALLBUFSIZE], buf[MAXBUFSIZE], puf[MAXBUFSIZE]; snprintf(tag, sizeof(tag)-1, "A%d", *seq); snprintf(tagok, sizeof(tagok)-1, "A%d OK", (*seq)++); @@ -327,7 +326,7 @@ int list_folders(int sd, int *seq, char *folders, int foldersize, int use_ssl, s write1(sd, buf, use_ssl, data->ssl); - n = recvtimeoutssl(sd, buf, sizeof(buf), 10, use_ssl, data->ssl); + recvtimeoutssl(sd, buf, sizeof(buf), 10, use_ssl, data->ssl); p = &buf[0]; do { diff --git a/src/memc.c b/src/memc.c index 1c6ac7f6..0c73e76c 100644 --- a/src/memc.c +++ b/src/memc.c @@ -286,13 +286,12 @@ int memcached_increment(struct memcached_server *ptr, char *key, unsigned int ke char *memcached_get(struct memcached_server *ptr, char *key, unsigned int *len, unsigned int *flags){ - int rc; char *p; if(memcached_connect(ptr) != MEMCACHED_SUCCESS) return NULL; snprintf(ptr->buf, MAXBUFSIZE, "get %s \r\n", key); - rc = send(ptr->fd, ptr->buf, strlen(ptr->buf), 0); + send(ptr->fd, ptr->buf, strlen(ptr->buf), 0); ptr->last_read_bytes = __recvtimeout(ptr->fd, ptr->buf, MAXBUFSIZE, ptr->rcv_timeout); @@ -333,12 +332,11 @@ char *memcached_get(struct memcached_server *ptr, char *key, unsigned int *len, int memcached_mget(struct memcached_server *ptr, char *key){ - int rc; if(memcached_connect(ptr) != MEMCACHED_SUCCESS) return MEMCACHED_FAILURE; snprintf(ptr->buf, MAXBUFSIZE, "get %s \r\n", key); - rc = send(ptr->fd, ptr->buf, strlen(ptr->buf), 0); + send(ptr->fd, ptr->buf, strlen(ptr->buf), 0); ptr->last_read_bytes = __recvtimeout(ptr->fd, ptr->buf, MAXBUFSIZE, ptr->rcv_timeout); diff --git a/src/parser.c b/src/parser.c index c908bd86..0c9827cc 100644 --- a/src/parser.c +++ b/src/parser.c @@ -178,7 +178,7 @@ void storno_attachment(struct _state *state){ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int take_into_pieces, char *writebuffer, int writebuffersize, char *abuffer, int abuffersize, struct __config *cfg){ char *p, *q, puf[SMALLBUFSIZE]; unsigned char b64buffer[MAXBUFSIZE]; - int t, x, n, n64, len, writelen, b64_len, boundary_line=0; + int t, n64, len, writelen, boundary_line=0; if(cfg->debug == 1) printf("line: %s", buf); @@ -226,7 +226,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int if(state->message_state == MSG_BODY && state->fd != -1 && is_item_on_string(state->boundaries, buf) == 0){ //n = write(state->fd, buf, len); // WRITE if(len + state->abufpos > abuffersize-1){ - n = write(state->fd, abuffer, state->abufpos); + write(state->fd, abuffer, state->abufpos); if(state->b64fd != -1){ abuffer[state->abufpos] = '\0'; @@ -245,7 +245,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int //n = write(state->mfd, buf, len); // WRITE if(len + state->writebufpos > writebuffersize-1){ if(sdata->ms_journal == 1) remove_trailing_journal_boundary(sdata, state, writebuffer); - n = write(state->mfd, writebuffer, state->writebufpos); state->writebufpos = 0; memset(writebuffer, 0, writebuffersize); + write(state->mfd, writebuffer, state->writebufpos); state->writebufpos = 0; memset(writebuffer, 0, writebuffersize); } memcpy(writebuffer+state->writebufpos, buf, len); state->writebufpos += len; } @@ -292,7 +292,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int //n = write(state->mfd, puf, strlen(puf)); // WRITE writelen = strlen(puf); if(writelen + state->writebufpos > writebuffersize-1){ - n = write(state->mfd, writebuffer, state->writebufpos); state->writebufpos = 0; memset(writebuffer, 0, writebuffersize); + write(state->mfd, writebuffer, state->writebufpos); state->writebufpos = 0; memset(writebuffer, 0, writebuffersize); } memcpy(writebuffer+state->writebufpos, puf, writelen); state->writebufpos += writelen; } @@ -363,7 +363,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int if((p = strcasestr(buf, "boundary"))){ - x = extract_boundary(p, state); + extract_boundary(p, state); } @@ -497,7 +497,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int if(state->has_to_dump == 1){ if(take_into_pieces == 1 && state->fd != -1){ if(state->abufpos > 0){ - n = write(state->fd, abuffer, state->abufpos); + write(state->fd, abuffer, state->abufpos); if(state->b64fd != -1){ abuffer[state->abufpos] = '\0'; @@ -549,7 +549,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int if(state->base64 == 1 && state->message_state == MSG_BODY){ - b64_len = decodeBase64(buf); + decodeBase64(buf); fixupBase64EncodedLine(buf, state); } diff --git a/src/pileraget.c b/src/pileraget.c index a17eb278..4d0d46bd 100644 --- a/src/pileraget.c +++ b/src/pileraget.c @@ -17,7 +17,7 @@ int main(int argc, char **argv){ - int rc, readkey=1; + int readkey=1; char filename[SMALLBUFSIZE]; struct __config cfg; @@ -45,7 +45,7 @@ int main(int argc, char **argv){ snprintf(filename, sizeof(filename)-1, "%s/%c%c/%c%c/%c%c/%s.a%d", cfg.queuedir, argv[1][RND_STR_LEN-6], argv[1][RND_STR_LEN-5], argv[1][RND_STR_LEN-4], argv[1][RND_STR_LEN-3], argv[1][RND_STR_LEN-2], argv[1][RND_STR_LEN-1], argv[1], atoi(argv[2])); - rc = retrieve_file_from_archive(filename, WRITE_TO_STDOUT, NULL, stdout, &cfg); + retrieve_file_from_archive(filename, WRITE_TO_STDOUT, NULL, stdout, &cfg); return 0; } diff --git a/src/pilerget.c b/src/pilerget.c index e53db9e7..52aa47a4 100644 --- a/src/pilerget.c +++ b/src/pilerget.c @@ -17,7 +17,7 @@ int main(int argc, char **argv){ - int rc, readkey=1; + int readkey=1; struct session_data sdata; struct __config cfg; @@ -52,7 +52,7 @@ int main(int argc, char **argv){ snprintf(sdata.ttmpfile, SMALLBUFSIZE-1, "%s", argv[1]); snprintf(sdata.filename, SMALLBUFSIZE-1, "%s", sdata.ttmpfile); - rc = retrieve_email_from_archive(&sdata, stdout, &cfg); + retrieve_email_from_archive(&sdata, stdout, &cfg); mysql_close(&(sdata.mysql)); diff --git a/src/test.c b/src/test.c index a1caa1ac..d02c1a88 100644 --- a/src/test.c +++ b/src/test.c @@ -16,7 +16,7 @@ int main(int argc, char **argv){ - int i, rc; + int i; struct stat st; struct session_data sdata; struct _state state; @@ -60,8 +60,6 @@ int main(int argc, char **argv){ load_rules(&sdata, &(data.archiving_rules), SQL_ARCHIVING_RULE_TABLE); load_rules(&sdata, &(data.retention_rules), SQL_RETENTION_RULE_TABLE); - rc = 0; - init_session_data(&sdata); sdata.sent = 0;