From fb759fec848fed0b81d484ba34b214c753a6a50d Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 8 Oct 2015 22:19:52 +0200 Subject: [PATCH] Rename some shadow variables This removes some warnings in gcc 4.6 version. --- cmdline/check.c | 46 ++++++++++++++++++------------------ cmdline/dup.c | 10 ++++---- cmdline/elem.c | 40 ++++++++++++++++---------------- cmdline/elem.h | 26 ++++++++++----------- cmdline/list.c | 8 +++---- cmdline/murmur3.c | 8 +++---- cmdline/pool.c | 4 ++-- cmdline/scan.c | 58 +++++++++++++++++++++++----------------------- cmdline/snapraid.c | 52 ++++++++++++++++++++--------------------- cmdline/spooky2.c | 10 ++++---- cmdline/state.c | 40 ++++++++++++++++---------------- cmdline/status.c | 4 ++-- cmdline/unix.c | 4 ++-- 13 files changed, 155 insertions(+), 155 deletions(-) diff --git a/cmdline/check.c b/cmdline/check.c index 348a962c..950dc881 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -1503,37 +1503,37 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna char linkto[PATH_MAX]; struct stat st; struct stat stto; - struct snapraid_link* link; + struct snapraid_link* slink; int unsuccesful = 0; int unrecoverable = 0; - link = node->data; + slink = node->data; node = node->next; /* next node */ /* if excluded continue to the next one */ - if (link_flag_has(link, FILE_IS_EXCLUDED)) { + if (link_flag_has(slink, FILE_IS_EXCLUDED)) { continue; } - if (link_flag_has(link, FILE_IS_HARDLINK)) { + if (link_flag_has(slink, FILE_IS_HARDLINK)) { /* stat the link */ - pathprint(path, sizeof(path), "%s%s", disk->dir, link->sub); + pathprint(path, sizeof(path), "%s%s", disk->dir, slink->sub); ret = stat(path, &st); if (ret == -1) { unsuccesful = 1; log_error("Error stating hardlink '%s'. %s.\n", path, strerror(errno)); - log_tag("hardlink_error:%s:%s:%s: Hardlink stat error\n", disk->name, esc(link->sub), esc(link->linkto)); + log_tag("hardlink_error:%s:%s:%s: Hardlink stat error\n", disk->name, esc(slink->sub), esc(slink->linkto)); ++error; } else if (!S_ISREG(st.st_mode)) { unsuccesful = 1; - log_tag("hardlink_error:%s:%s:%s: Hardlink error for not regular file\n", disk->name, esc(link->sub), esc(link->linkto)); + log_tag("hardlink_error:%s:%s:%s: Hardlink error for not regular file\n", disk->name, esc(slink->sub), esc(slink->linkto)); ++error; } /* stat the "to" file */ - pathprint(pathto, sizeof(pathto), "%s%s", disk->dir, link->linkto); + pathprint(pathto, sizeof(pathto), "%s%s", disk->dir, slink->linkto); ret = stat(pathto, &stto); if (ret == -1) { unsuccesful = 1; @@ -1553,43 +1553,43 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna } log_error("Error stating hardlink-to '%s'. %s.\n", pathto, strerror(errno)); - log_tag("hardlink_error:%s:%s:%s: Hardlink to stat error\n", disk->name, esc(link->sub), esc(link->linkto)); + log_tag("hardlink_error:%s:%s:%s: Hardlink to stat error\n", disk->name, esc(slink->sub), esc(slink->linkto)); ++error; } else if (!S_ISREG(stto.st_mode)) { unsuccesful = 1; - log_tag("hardlink_error:%s:%s:%s: Hardlink-to error for not regular file\n", disk->name, esc(link->sub), esc(link->linkto)); + log_tag("hardlink_error:%s:%s:%s: Hardlink-to error for not regular file\n", disk->name, esc(slink->sub), esc(slink->linkto)); ++error; } else if (!unsuccesful && st.st_ino != stto.st_ino) { unsuccesful = 1; log_error("Mismatch hardlink '%s' and '%s'. Different inode.\n", path, pathto); - log_tag("hardlink_error:%s:%s:%s: Hardlink mismatch for different inode\n", disk->name, esc(link->sub), esc(link->linkto)); + log_tag("hardlink_error:%s:%s:%s: Hardlink mismatch for different inode\n", disk->name, esc(slink->sub), esc(slink->linkto)); ++error; } } else { /* read the symlink */ - pathprint(path, sizeof(path), "%s%s", disk->dir, link->sub); + pathprint(path, sizeof(path), "%s%s", disk->dir, slink->sub); ret = readlink(path, linkto, sizeof(linkto)); if (ret < 0) { unsuccesful = 1; log_error("Error reading symlink '%s'. %s.\n", path, strerror(errno)); - log_tag("symlink_error:%s:%s: Symlink read error\n", disk->name, esc(link->sub)); + log_tag("symlink_error:%s:%s: Symlink read error\n", disk->name, esc(slink->sub)); ++error; } else if (ret >= PATH_MAX) { unsuccesful = 1; log_error("Error reading symlink '%s'. Symlink too long.\n", path); - log_tag("symlink_error:%s:%s: Symlink read error\n", disk->name, esc(link->sub)); + log_tag("symlink_error:%s:%s: Symlink read error\n", disk->name, esc(slink->sub)); ++error; } else { linkto[ret] = 0; - if (strcmp(linkto, link->linkto) != 0) { + if (strcmp(linkto, slink->linkto) != 0) { unsuccesful = 1; - log_tag("symlink_error:%s:%s: Symlink data error '%s' instead of '%s'\n", disk->name, esc(link->sub), linkto, link->linkto); + log_tag("symlink_error:%s:%s: Symlink data error '%s' instead of '%s'\n", disk->name, esc(slink->sub), linkto, slink->linkto); ++error; } } @@ -1620,7 +1620,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna } /* create it */ - if (link_flag_has(link, FILE_IS_HARDLINK)) { + if (link_flag_has(slink, FILE_IS_HARDLINK)) { ret = hardlink(pathto, path); if (ret != 0) { /* LCOV_EXCL_START */ @@ -1637,13 +1637,13 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna /* LCOV_EXCL_STOP */ } - log_tag("hardlink_fixed:%s:%s: Fixed hardlink error\n", disk->name, esc(link->sub)); + log_tag("hardlink_fixed:%s:%s: Fixed hardlink error\n", disk->name, esc(slink->sub)); ++recovered_error; } else { - ret = symlink(link->linkto, path); + ret = symlink(slink->linkto, path); if (ret != 0) { /* LCOV_EXCL_START */ - log_fatal("Error writing symlink '%s' to '%s'. %s.\n", path, link->linkto, strerror(errno)); + log_fatal("Error writing symlink '%s' to '%s'. %s.\n", path, slink->linkto, strerror(errno)); if (errno == EACCES) { log_fatal("WARNING! Please give write permission to the symlink.\n"); } else { @@ -1656,12 +1656,12 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna /* LCOV_EXCL_STOP */ } - log_tag("symlink_fixed:%s:%s: Fixed symlink error\n", disk->name, esc(link->sub)); + log_tag("symlink_fixed:%s:%s: Fixed symlink error\n", disk->name, esc(slink->sub)); ++recovered_error; } - log_tag("status:recovered:%s:%s\n", disk->name, esc(link->sub)); - msg_info("recovered %s%s\n", disk->dir, link->sub); + log_tag("status:recovered:%s:%s\n", disk->name, esc(slink->sub)); + msg_info("recovered %s%s\n", disk->dir, slink->sub); } } diff --git a/cmdline/dup.c b/cmdline/dup.c index c5d209c3..1a33055e 100644 --- a/cmdline/dup.c +++ b/cmdline/dup.c @@ -123,12 +123,12 @@ void state_dup(struct snapraid_state* state) hash32 = hash_hash(hash); - struct snapraid_hash* dup = tommy_hashdyn_search(&hashset, hash_compare, hash->hash, hash32); - if (dup) { + struct snapraid_hash* found = tommy_hashdyn_search(&hashset, hash_compare, hash->hash, hash32); + if (found) { ++count; - size += dup->file->size; - log_tag("dup:%s:%s:%s:%s:%" PRIu64 ": dup\n", disk->name, esc(file->sub), dup->disk->name, esc(dup->file->sub), dup->file->size); - printf("%12" PRIu64 " %s%s = %s%s\n", file->size, disk->dir, file->sub, dup->disk->dir, dup->file->sub); + size += found->file->size; + log_tag("dup:%s:%s:%s:%s:%" PRIu64 ": dup\n", disk->name, esc(file->sub), found->disk->name, esc(found->file->sub), found->file->size); + printf("%12" PRIu64 " %s%s = %s%s\n", file->size, disk->dir, file->sub, found->disk->dir, found->file->sub); hash_free(hash); } else { tommy_hashdyn_insert(&hashset, &hash->node, hash, hash32); diff --git a/cmdline/elem.c b/cmdline/elem.c index da7ece51..247c2fee 100644 --- a/cmdline/elem.c +++ b/cmdline/elem.c @@ -469,13 +469,13 @@ unsigned file_block_size(struct snapraid_file* file, block_off_t file_pos, unsig { /* if it's the last block */ if (file_pos + 1 == file->blockmax) { - unsigned remainder; + unsigned block_remainder; if (file->size == 0) return 0; - remainder = file->size % block_size; - if (remainder == 0) - remainder = block_size; - return remainder; + block_remainder = file->size % block_size; + if (block_remainder == 0) + block_remainder = block_size; + return block_remainder; } return block_size; @@ -654,37 +654,37 @@ int chunk_file_compare(const void* void_a, const void* void_b) struct snapraid_link* link_alloc(const char* sub, const char* linkto, unsigned link_flag) { - struct snapraid_link* link; + struct snapraid_link* slink; - link = malloc_nofail(sizeof(struct snapraid_link)); - link->sub = strdup_nofail(sub); - link->linkto = strdup_nofail(linkto); - link->flag = link_flag; + slink = malloc_nofail(sizeof(struct snapraid_link)); + slink->sub = strdup_nofail(sub); + slink->linkto = strdup_nofail(linkto); + slink->flag = link_flag; - return link; + return slink; } -void link_free(struct snapraid_link* link) +void link_free(struct snapraid_link* slink) { - free(link->sub); - free(link->linkto); - free(link); + free(slink->sub); + free(slink->linkto); + free(slink); } int link_name_compare_to_arg(const void* void_arg, const void* void_data) { const char* arg = void_arg; - const struct snapraid_link* link = void_data; + const struct snapraid_link* slink = void_data; - return strcmp(arg, link->sub); + return strcmp(arg, slink->sub); } int link_alpha_compare(const void* void_a, const void* void_b) { - const struct snapraid_link* link_a = void_a; - const struct snapraid_link* link_b = void_b; + const struct snapraid_link* slink_a = void_a; + const struct snapraid_link* slink_b = void_b; - return strcmp(link_a->sub, link_b->sub); + return strcmp(slink_a->sub, slink_b->sub); } struct snapraid_dir* dir_alloc(const char* sub) diff --git a/cmdline/elem.h b/cmdline/elem.h index cf6f0553..79672659 100644 --- a/cmdline/elem.h +++ b/cmdline/elem.h @@ -762,41 +762,41 @@ int chunk_parity_compare(const void* void_a, const void* void_b); */ int chunk_file_compare(const void* void_a, const void* void_b); -static inline int link_flag_has(const struct snapraid_link* link, unsigned mask) +static inline int link_flag_has(const struct snapraid_link* slink, unsigned mask) { - return (link->flag & mask) == mask; + return (slink->flag & mask) == mask; } -static inline void link_flag_set(struct snapraid_link* link, unsigned mask) +static inline void link_flag_set(struct snapraid_link* slink, unsigned mask) { - link->flag |= mask; + slink->flag |= mask; } -static inline void link_flag_clear(struct snapraid_link* link, unsigned mask) +static inline void link_flag_clear(struct snapraid_link* slink, unsigned mask) { - link->flag &= ~mask; + slink->flag &= ~mask; } -static inline void link_flag_let(struct snapraid_link* link, unsigned flag, unsigned mask) +static inline void link_flag_let(struct snapraid_link* slink, unsigned flag, unsigned mask) { - link->flag &= ~mask; - link->flag |= flag & mask; + slink->flag &= ~mask; + slink->flag |= flag & mask; } -static inline unsigned link_flag_get(struct snapraid_link* link, unsigned mask) +static inline unsigned link_flag_get(struct snapraid_link* slink, unsigned mask) { - return link->flag & mask; + return slink->flag & mask; } /** * Allocate a link. */ -struct snapraid_link* link_alloc(const char* name, const char* link, unsigned link_flag); +struct snapraid_link* link_alloc(const char* name, const char* slink, unsigned link_flag); /** * Deallocate a link. */ -void link_free(struct snapraid_link* link); +void link_free(struct snapraid_link* slink); /** * Compare a link with a name. diff --git a/cmdline/list.c b/cmdline/list.c index 3d0dbe9a..558fdfa6 100644 --- a/cmdline/list.c +++ b/cmdline/list.c @@ -83,10 +83,10 @@ void state_list(struct snapraid_state* state) /* for each link */ for (j = disk->linklist; j != 0; j = j->next) { - struct snapraid_link* link = j->data; + struct snapraid_link* slink = j->data; const char* type; - switch (link->flag & FILE_IS_LINK_MASK) { + switch (slink->flag & FILE_IS_LINK_MASK) { case FILE_IS_HARDLINK : type = "hardlink"; break; case FILE_IS_SYMLINK : type = "symlink"; break; case FILE_IS_SYMDIR : type = "symdir"; break; @@ -98,13 +98,13 @@ void state_list(struct snapraid_state* state) ++link_count; - log_tag("link_%s:%s:%s:%s\n", type, disk->name, esc(link->sub), esc(link->linkto)); + log_tag("link_%s:%s:%s:%s\n", type, disk->name, esc(slink->sub), esc(slink->linkto)); printf("%12s ", type); printf(" "); if (msg_level >= MSG_VERBOSE) printf(" "); - printf("%s%s -> %s%s\n", disk->dir, link->sub, disk->dir, link->linkto); + printf("%s%s -> %s%s\n", disk->dir, slink->sub, disk->dir, slink->linkto); } } diff --git a/cmdline/murmur3.c b/cmdline/murmur3.c index 41a19432..4c23b2b0 100644 --- a/cmdline/murmur3.c +++ b/cmdline/murmur3.c @@ -80,7 +80,7 @@ void MurmurHash3_x86_128(const void* data, size_t size, const uint8_t* seed, voi size_t nblocks; const uint32_t* blocks; const uint32_t* end; - size_t remainder; + size_t size_remainder; uint32_t h1 = ((const uint32_t*)seed)[0]; uint32_t h2 = ((const uint32_t*)seed)[1]; @@ -132,8 +132,8 @@ void MurmurHash3_x86_128(const void* data, size_t size, const uint8_t* seed, voi } /* tail */ - remainder = size & 15; - if (remainder != 0) { + size_remainder = size & 15; + if (size_remainder != 0) { const uint8_t* tail = (const uint8_t*)blocks; uint32_t k1 = 0; @@ -141,7 +141,7 @@ void MurmurHash3_x86_128(const void* data, size_t size, const uint8_t* seed, voi uint32_t k3 = 0; uint32_t k4 = 0; - switch (remainder) { + switch (size_remainder) { case 15 : k4 ^= tail[14] << 16; case 14 : k4 ^= tail[13] << 8; case 13 : k4 ^= tail[12] << 0; diff --git a/cmdline/pool.c b/cmdline/pool.c index 385186e5..034ce674 100644 --- a/cmdline/pool.c +++ b/cmdline/pool.c @@ -242,8 +242,8 @@ void state_pool(struct snapraid_state* state) /* for each link */ for (j = disk->linklist; j != 0; j = j->next) { - struct snapraid_link* link = j->data; - make_link(pool_dir, share_dir, disk, link->sub); + struct snapraid_link* slink = j->data; + make_link(pool_dir, share_dir, disk, slink->sub); ++count; } diff --git a/cmdline/scan.c b/cmdline/scan.c index d29d2bdd..5031ecd6 100644 --- a/cmdline/scan.c +++ b/cmdline/scan.c @@ -48,7 +48,7 @@ struct snapraid_scan { /** * Remove the specified link from the data set. */ -static void scan_link_remove(struct snapraid_scan* scan, struct snapraid_link* link) +static void scan_link_remove(struct snapraid_scan* scan, struct snapraid_link* slink) { struct snapraid_state* state = scan->state; struct snapraid_disk* disk = scan->disk; @@ -57,17 +57,17 @@ static void scan_link_remove(struct snapraid_scan* scan, struct snapraid_link* l state->need_write = 1; /* remove the file from the link containers */ - tommy_hashdyn_remove_existing(&disk->linkset, &link->nodeset); - tommy_list_remove_existing(&disk->linklist, &link->nodelist); + tommy_hashdyn_remove_existing(&disk->linkset, &slink->nodeset); + tommy_list_remove_existing(&disk->linklist, &slink->nodelist); /* deallocate */ - link_free(link); + link_free(slink); } /** * Insert the specified link in the data set. */ -static void scan_link_insert(struct snapraid_scan* scan, struct snapraid_link* link) +static void scan_link_insert(struct snapraid_scan* scan, struct snapraid_link* slink) { struct snapraid_state* state = scan->state; struct snapraid_disk* disk = scan->disk; @@ -76,8 +76,8 @@ static void scan_link_insert(struct snapraid_scan* scan, struct snapraid_link* l state->need_write = 1; /* insert the link in the link containers */ - tommy_hashdyn_insert(&disk->linkset, &link->nodeset, link, link_name_hash(link->sub)); - tommy_list_insert_tail(&disk->linklist, &link->nodelist, link); + tommy_hashdyn_insert(&disk->linkset, &slink->nodeset, slink, link_name_hash(slink->sub)); + tommy_list_insert_tail(&disk->linklist, &slink->nodelist, slink); } /** @@ -87,13 +87,13 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub, { struct snapraid_state* state = scan->state; struct snapraid_disk* disk = scan->disk; - struct snapraid_link* link; + struct snapraid_link* slink; /* check if the link already exists */ - link = tommy_hashdyn_search(&disk->linkset, link_name_compare_to_arg, sub, link_name_hash(sub)); - if (link) { + slink = tommy_hashdyn_search(&disk->linkset, link_name_compare_to_arg, sub, link_name_hash(sub)); + if (slink) { /* check if multiple files have the same name */ - if (link_flag_has(link, FILE_IS_PRESENT)) { + if (link_flag_has(slink, FILE_IS_PRESENT)) { /* LCOV_EXCL_START */ log_fatal("Internal inconsistency for link '%s%s'\n", disk->dir, sub); exit(EXIT_FAILURE); @@ -101,15 +101,15 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub, } /* mark as present */ - link_flag_set(link, FILE_IS_PRESENT); + link_flag_set(slink, FILE_IS_PRESENT); /* check if the link is not changed and it's of the same kind */ - if (strcmp(link->linkto, linkto) == 0 && link_flag == link_flag_get(link, FILE_IS_LINK_MASK)) { + if (strcmp(slink->linkto, linkto) == 0 && link_flag == link_flag_get(slink, FILE_IS_LINK_MASK)) { /* it's equal */ ++scan->count_equal; if (state->opt.gui) { - log_tag("scan:equal:%s:%s\n", disk->name, esc(link->sub)); + log_tag("scan:equal:%s:%s\n", disk->name, esc(slink->sub)); } } else { /* it's an update */ @@ -119,15 +119,15 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub, ++scan->count_change; - log_tag("scan:update:%s:%s\n", disk->name, esc(link->sub)); + log_tag("scan:update:%s:%s\n", disk->name, esc(slink->sub)); if (is_diff) { - printf("update %s%s\n", disk->dir, link->sub); + printf("update %s%s\n", disk->dir, slink->sub); } /* update it */ - free(link->linkto); - link->linkto = strdup_nofail(linkto); - link_flag_let(link, link_flag, FILE_IS_LINK_MASK); + free(slink->linkto); + slink->linkto = strdup_nofail(linkto); + link_flag_let(slink, link_flag, FILE_IS_LINK_MASK); } /* nothing more to do */ @@ -145,13 +145,13 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub, } /* insert it */ - link = link_alloc(sub, linkto, link_flag); + slink = link_alloc(sub, linkto, link_flag); /* mark it as present */ - link_flag_set(link, FILE_IS_PRESENT); + link_flag_set(slink, FILE_IS_PRESENT); /* insert it in the delayed insert list */ - tommy_list_insert_tail(&scan->link_insert_list, &link->nodelist, link); + tommy_list_insert_tail(&scan->link_insert_list, &slink->nodelist, slink); } /** @@ -1493,21 +1493,21 @@ static int state_diffscan(struct snapraid_state* state, int is_diff) /* check for removed links */ node = disk->linklist; while (node) { - struct snapraid_link* link = node->data; + struct snapraid_link* slink = node->data; /* next node */ node = node->next; /* remove if not present */ - if (!link_flag_has(link, FILE_IS_PRESENT)) { + if (!link_flag_has(slink, FILE_IS_PRESENT)) { ++scan->count_remove; - log_tag("scan:remove:%s:%s\n", disk->name, esc(link->sub)); + log_tag("scan:remove:%s:%s\n", disk->name, esc(slink->sub)); if (is_diff) { - printf("remove %s%s\n", disk->dir, link->sub); + printf("remove %s%s\n", disk->dir, slink->sub); } - scan_link_remove(scan, link); + scan_link_remove(scan, slink); } } @@ -1588,13 +1588,13 @@ static int state_diffscan(struct snapraid_state* state, int is_diff) /* insert all the new links */ node = scan->link_insert_list; while (node) { - struct snapraid_link* link = node->data; + struct snapraid_link* slink = node->data; /* next node */ node = node->next; /* insert it */ - scan_link_insert(scan, link); + scan_link_insert(scan, slink); } /* insert all the new dirs */ diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index 17afa3fa..6a86bd37 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -91,7 +91,7 @@ void memory(void) /****************************************************************************/ /* log */ -void log_open(const char* log) +void log_open(const char* file) { char path[PATH_MAX]; const char* mode; @@ -101,7 +101,7 @@ void log_open(const char* log) struct tm* tm; /* leave stdlog at 0 if not specified */ - if (log == 0) + if (file == 0) return; t = time(0); @@ -118,31 +118,31 @@ void log_open(const char* log) /* file mode */ mode = "wt"; - if (*log == '>') { - ++log; + if (*file == '>') { + ++file; - if (*log == '>') { + if (*file == '>') { mode = "at"; - ++log; + ++file; } - if (log[0] == '&' && log[1] == '1') { + if (file[0] == '&' && file[1] == '1') { stdlog = stdout; return; } - if (log[0] == '&' && log[1] == '2') { + if (file[0] == '&' && file[1] == '2') { stdlog = stderr; return; } } /* process the path */ - for (*path = 0; *log != 0; ) { - switch (*log) { + for (*path = 0; *file != 0; ) { + switch (*file) { case '%' : - ++log; - switch (*log) { + ++file; + switch (*file) { case '%' : pathcatc(path, sizeof(path), '%'); break; @@ -154,16 +154,16 @@ void log_open(const char* log) break; default : /* LCOV_EXCL_START */ - log_fatal("Invalid type specifier '%c' in the log file.\n", *log); + log_fatal("Invalid type specifier '%c' in the log file.\n", *file); exit(EXIT_FAILURE); /* LCOV_EXCL_STOP */ } break; default : - pathcatc(path, sizeof(path), *log); + pathcatc(path, sizeof(path), *file); break; } - ++log; + ++file; } stdlog = fopen(path, mode); @@ -175,12 +175,12 @@ void log_open(const char* log) } } -void log_close(const char* log) +void log_close(const char* file) { if (stdlog != stdout && stdlog != stderr && stdlog != 0) { if (fclose(stdlog) != 0) { /* LCOV_EXCL_START */ - log_fatal("Error closing the log file '%s'. %s.\n", log, strerror(errno)); + log_fatal("Error closing the log file '%s'. %s.\n", file, strerror(errno)); exit(EXIT_FAILURE); /* LCOV_EXCL_STOP */ } @@ -368,9 +368,9 @@ struct option long_options[] = { volatile int global_interrupt = 0; /* LCOV_EXCL_START */ -void signal_handler(int signal) +void signal_handler(int signum) { - switch (signal) { + switch (signum) { case SIGINT : global_interrupt = 1; break; @@ -417,7 +417,7 @@ int main(int argc, char* argv[]) const char* command; const char* import_timestamp; const char* import_content; - const char* log; + const char* log_file; int lock; const char* gen_conf; const char* run; @@ -442,7 +442,7 @@ int main(int argc, char* argv[]) olderthan = SCRUB_AUTO; import_timestamp = 0; import_content = 0; - log = 0; + log_file = 0; lock = 0; gen_conf = 0; speedtest = 0; @@ -564,13 +564,13 @@ int main(int argc, char* argv[]) import_content = optarg; break; case 'l' : - if (log) { + if (log_file) { /* LCOV_EXCL_START */ - log_fatal("Log file '%s' already specified as '%s'\n", optarg, log); + log_fatal("Log file '%s' already specified as '%s'\n", optarg, log_file); exit(EXIT_FAILURE); /* LCOV_EXCL_STOP */ } - log = optarg; + log_file = optarg; break; case 'Z' : opt.force_zero = 1; @@ -938,7 +938,7 @@ int main(int argc, char* argv[]) } /* open the log file */ - log_open(log); + log_open(log_file); /* print generic info into the log */ t = time(0); @@ -1212,7 +1212,7 @@ int main(int argc, char* argv[]) } /* close log file */ - log_close(log); + log_close(log_file); #if HAVE_LOCKFILE if (!opt.skip_lock) { diff --git a/cmdline/spooky2.c b/cmdline/spooky2.c index 8d2a0334..3658d2fd 100644 --- a/cmdline/spooky2.c +++ b/cmdline/spooky2.c @@ -115,7 +115,7 @@ void SpookyHash128(const void* data, size_t size, const uint8_t* seed, uint8_t* size_t nblocks; const uint64_t* blocks; const uint64_t* end; - size_t remainder; + size_t size_remainder; #if WORDS_BIGENDIAN unsigned i; #endif @@ -149,10 +149,10 @@ void SpookyHash128(const void* data, size_t size, const uint8_t* seed, uint8_t* } /* tail */ - remainder = (size - ((const uint8_t*)end - (const uint8_t*)data)); - memcpy(buf, end, remainder); - memset(((uint8_t*)buf) + remainder, 0, sc_blockSize - remainder); - ((uint8_t*)buf)[sc_blockSize - 1] = remainder; + size_remainder = (size - ((const uint8_t*)end - (const uint8_t*)data)); + memcpy(buf, end, size_remainder); + memset(((uint8_t*)buf) + size_remainder, 0, sc_blockSize - size_remainder); + ((uint8_t*)buf)[sc_blockSize - 1] = size_remainder; /* finalization */ #if WORDS_BIGENDIAN diff --git a/cmdline/state.c b/cmdline/state.c index 481307e4..10b868b1 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -2005,7 +2005,7 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST /* symlink */ char sub[PATH_MAX]; char linkto[PATH_MAX]; - struct snapraid_link* link; + struct snapraid_link* slink; struct snapraid_disk* disk; uint32_t mapping; @@ -2043,11 +2043,11 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST } /* allocate the link as symbolic link */ - link = link_alloc(sub, linkto, FILE_IS_SYMLINK); + slink = link_alloc(sub, linkto, FILE_IS_SYMLINK); /* insert the link in the link containers */ - tommy_hashdyn_insert(&disk->linkset, &link->nodeset, link, link_name_hash(link->sub)); - tommy_list_insert_tail(&disk->linklist, &link->nodelist, link); + tommy_hashdyn_insert(&disk->linkset, &slink->nodeset, slink, link_name_hash(slink->sub)); + tommy_list_insert_tail(&disk->linklist, &slink->nodelist, slink); /* stat */ ++count_symlink; @@ -2055,7 +2055,7 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST /* hardlink */ char sub[PATH_MAX]; char linkto[PATH_MAX]; - struct snapraid_link* link; + struct snapraid_link* slink; struct snapraid_disk* disk; uint32_t mapping; @@ -2093,11 +2093,11 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST } /* allocate the link as hard link */ - link = link_alloc(sub, linkto, FILE_IS_HARDLINK); + slink = link_alloc(sub, linkto, FILE_IS_HARDLINK); /* insert the link in the link containers */ - tommy_hashdyn_insert(&disk->linkset, &link->nodeset, link, link_name_hash(link->sub)); - tommy_list_insert_tail(&disk->linklist, &link->nodelist, link); + tommy_hashdyn_insert(&disk->linkset, &slink->nodeset, slink, link_name_hash(slink->sub)); + tommy_list_insert_tail(&disk->linklist, &slink->nodelist, slink); /* stat */ ++count_hardlink; @@ -2465,10 +2465,10 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f) /* only if there is some info to store */ if (info) { - time_t time = info_get_time(info); + time_t info_time = info_get_time(info); - if (!info_oldest || time < info_oldest) - info_oldest = time; + if (!info_oldest || info_time < info_oldest) + info_oldest = info_time; if (info_get_rehash(info)) info_has_rehash = 1; @@ -2699,9 +2699,9 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f) /* for each link */ for (j = disk->linklist; j != 0; j = j->next) { - struct snapraid_link* link = j->data; + struct snapraid_link* slink = j->data; - switch (link_flag_get(link, FILE_IS_LINK_MASK)) { + switch (link_flag_get(slink, FILE_IS_LINK_MASK)) { case FILE_IS_HARDLINK : sputc('a', f); ++count_hardlink; @@ -2713,8 +2713,8 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f) } sputb32(disk->mapping_idx, f); - sputbs(link->sub, f); - sputbs(link->linkto, f); + sputbs(slink->sub, f); + sputbs(slink->linkto, f); if (serror(f)) { /* LCOV_EXCL_START */ log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); @@ -3171,13 +3171,13 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist_file, tom /* for each link */ for (j = tommy_list_head(&disk->linklist); j != 0; j = j->next) { - struct snapraid_link* link = j->data; + struct snapraid_link* slink = j->data; - if (filter_path(filterlist_disk, 0, disk->name, link->sub) != 0 - || filter_path(filterlist_file, 0, disk->name, link->sub) != 0 - || filter_existence(filter_missing, disk->dir, link->sub) != 0 + if (filter_path(filterlist_disk, 0, disk->name, slink->sub) != 0 + || filter_path(filterlist_file, 0, disk->name, slink->sub) != 0 + || filter_existence(filter_missing, disk->dir, slink->sub) != 0 ) { - link_flag_set(link, FILE_IS_EXCLUDED); + link_flag_set(slink, FILE_IS_EXCLUDED); } } diff --git a/cmdline/status.c b/cmdline/status.c index d807c0cd..532f1371 100644 --- a/cmdline/status.c +++ b/cmdline/status.c @@ -27,9 +27,9 @@ /****************************************************************************/ /* status */ -unsigned day_ago(time_t time, time_t now) +unsigned day_ago(time_t ref, time_t now) { - return (now - time) / (24 * 3600); + return (now - ref) / (24 * 3600); } #define GRAPH_COLUMN 70 diff --git a/cmdline/unix.c b/cmdline/unix.c index 037e5a46..9d7ff0d6 100644 --- a/cmdline/unix.c +++ b/cmdline/unix.c @@ -752,13 +752,13 @@ static int devdown(dev_t device, const char* name, const char* custom) * There isn't a defined way to spin up a device, * so we just do a generic write. */ -static int devup(const char* mount) +static int devup(const char* mountpoint) { int ret; char path[PATH_MAX]; /* add a temporary name used for writing */ - pathprint(path, sizeof(path), "%s.snapraid-spinup", mount); + pathprint(path, sizeof(path), "%s.snapraid-spinup", mountpoint); /* do a generic write, and immediately undo it */ ret = mkdir(path, 0);