From 31d2837dac3571baec6b2bd19ec8475617833ad7 Mon Sep 17 00:00:00 2001 From: jay Date: Tue, 26 Jun 2007 08:24:17 +0000 Subject: [PATCH] Fix Savannah bug #20263 (compilation err on DEC OSF/1. Include in files where where we use struct stat. Removed some dead code following some calls to assert(0), which are now backed up by abort calls. Use assert (0) rather than assert (false). Make sure we include the space. --- ChangeLog | 40 +++++++++++++++++++++++++++ NEWS | 2 ++ build-aux/src-sniff.py | 18 +++++++++++- find/find.c | 14 +++++----- find/fstype.c | 2 +- find/ftsfind.c | 13 +++++---- find/parser.c | 26 +++++++++--------- find/pred.c | 74 +++++++++++++++++++++++++------------------------- find/tree.c | 57 +++++++++++++++++++------------------- find/util.c | 14 +++++----- lib/buildcmd.c | 6 ++-- lib/buildcmd.h | 2 +- lib/extendbuf.c | 4 +-- locate/frcode.c | 4 +-- locate/locate.c | 2 +- locate/word_io.c | 2 +- xargs/xargs.c | 14 +++++----- 17 files changed, 176 insertions(+), 118 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2327145..4579e9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,45 @@ 2007-06-26 James Youngman + * build-aux/src-sniff.py: Detect uses of struct stat where the + header file was not included. + * find/find.c: Fix this, and uses of assert without a following + space (the coding standard requires a space, but there are still + a number of cases where other functions are called with no + following space). + * find/fstype.c: Ditto. + * find/ftsfind.c: Ditto. + * find/parser.c: Ditto. + * find/pred.c: Ditto. + * find/tree.c: Ditto. + * find/util.c: Ditto. + * lib/buildcmd.c: Ditto. + * lib/buildcmd.h: Ditto. + * lib/extendbuf.c: Ditto. + * locate/frcode.c: Ditto. + * locate/locate.c: Ditto. + * locate/word_io.c: Ditto. + * xargs/xargs.c: Ditto. + + * find/tree.c (cost_table_comparison): Avoid < comparison between + function pointer types. Instead cast the function pointers to + (const void*). Both alternatives are undefined C, but the former + actually fails to compile on some systems. This fixes Savannah + bug #20263. + * NEWS: mention the fix + + * find/tree.c (calculate_derived_rates): Removed assignment to + rate variable following an assert(0) call, which had been added to + silence a "used before initialised" warning, and replace it with a + call to abort, which (a) correctly halts execution if _NDEBUG is + defined and (b) more accurately documents what's happening. + + * find/parser.c (get_stat_Ytime): Removed redundant call to abort. + + * find/util.c (debug_stat): For consistency, use assert (0) rather + than assert (false). + +2007-06-26 James Youngman + * README-alpha: Mention the findutils-patches mailng list and the archives for findutils-patches and bug-findutils. diff --git a/NEWS b/NEWS index 82a6d9b..4ae957b 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ GNU findutils NEWS - User visible changes. -*- outline -*- (allout) * Major changes in release 4.3.9-CVS ** Bug Fixes +#20263: Compilation fix for DEC Alpha OSF/1 cc, which forbids the +ordering comparison of function pointers. #20139: find -[acm]time -N (wrongly) includes files from N days ago, as well as (correctly) from less than N days ago. diff --git a/build-aux/src-sniff.py b/build-aux/src-sniff.py index 7c75bf7..85e6506 100644 --- a/build-aux/src-sniff.py +++ b/build-aux/src-sniff.py @@ -58,6 +58,21 @@ def BuildIncludeList(text): return [m.group(1) for m in include_re.finditer(text)] +def CheckStatHeader(filename, lines, fulltext): + stat_hdr_re = re.compile(r'# *include .*') + # It's OK to have a pointer though. + stat_use_re = re.compile(r'struct stat\W *[^*]') + for line in lines: + m = stat_use_re.search(line[1]) + if m: + msgfmt = "%d: If you use struct stat, you must #include first" + Problem(filename, msgfmt % line[0]) + # Diagnose only once + break + m = stat_hdr_re.search(line[1]) + if m: + break + def CheckFirstInclude(filename, lines, fulltext): includes = BuildIncludeList(fulltext) if includes and includes[0] != FIRST_INCLUDE: @@ -88,7 +103,8 @@ def CheckFileSmells(filename, lines, fulltext): def SniffSourceFile(filename, lines, fulltext): - for sniffer in [CheckFirstInclude, CheckLineSmells, CheckFileSmells]: + for sniffer in [CheckFirstInclude, CheckStatHeader, + CheckLineSmells, CheckFileSmells]: sniffer(filename, lines, fulltext) diff --git a/find/find.c b/find/find.c index 1610e04..dd4f0e8 100644 --- a/find/find.c +++ b/find/find.c @@ -37,7 +37,7 @@ #include #include - +#include #ifdef HAVE_FCNTL_H #include #else @@ -198,7 +198,7 @@ main (int argc, char **argv) close (starting_desc); starting_desc = -1; } - assert(starting_desc >= 0); + assert (starting_desc >= 0); if (starting_desc < 0) { @@ -294,8 +294,8 @@ static size_t num_mounted_devices = 0u; static void init_mounted_dev_list(int mandatory) { - assert(NULL == mounted_devices); - assert(0 == num_mounted_devices); + assert (NULL == mounted_devices); + assert (0 == num_mounted_devices); mounted_devices = get_mounted_devices(&num_mounted_devices); if (mandatory && (NULL == mounted_devices)) { @@ -779,7 +779,7 @@ safely_chdir_lstat(const char *dest, } *did_stat = statflag; - assert(rv_set); + assert (rv_set); return rv; } @@ -1282,7 +1282,7 @@ process_dir (char *pathname, char *name, int pathlen, const struct stat *statp, if (dirinfo == NULL) { - assert(errno != 0); + assert (errno != 0); error (0, errno, "%s", safely_quote_err_filename(0, pathname)); state.exit_status = 1; } @@ -1509,6 +1509,6 @@ process_dir (char *pathname, char *name, int pathlen, const struct stat *statp, /* Make sure we hasn't used the variable subdirs_left if we knew * we shouldn't do so. */ - assert(0 == subdirs_left || options.no_leaf_check); + assert (0 == subdirs_left || options.no_leaf_check); } } diff --git a/find/fstype.c b/find/fstype.c index 7f0ca50..b10ffa6 100644 --- a/find/fstype.c +++ b/find/fstype.c @@ -27,12 +27,12 @@ #include #include -#include #include #ifdef HAVE_SYS_TYPES_H #include #endif +#include /* The presence of unistd.h is assumed by gnulib these days, so we * might as well assume it too. diff --git a/find/ftsfind.c b/find/ftsfind.c index 76f7966..cce7e33 100644 --- a/find/ftsfind.c +++ b/find/ftsfind.c @@ -44,6 +44,7 @@ #else #include #endif +#include #include @@ -106,8 +107,8 @@ int get_current_dirfd(void) { if (ftsoptions & FTS_CWDFD) { - assert(curr_fd != -1); - assert( (AT_FDCWD == curr_fd) || (curr_fd >= 0) ); + assert (curr_fd != -1); + assert ( (AT_FDCWD == curr_fd) || (curr_fd >= 0) ); if (AT_FDCWD == curr_fd) return starting_desc; @@ -145,7 +146,7 @@ static void inside_dir(int dirfd) { if (ftsoptions & FTS_CWDFD) { - assert(dirfd == AT_FDCWD || dirfd >= 0); + assert (dirfd == AT_FDCWD || dirfd >= 0); state.cwd_dir_fd = dirfd; if (curr_fd < 0) @@ -164,7 +165,7 @@ static void inside_dir(int dirfd) /* curr_fd is invalid, but dirfd is also invalid. * This should not have happened. */ - assert(curr_fd >= 0 || dirfd >= 0); + assert (curr_fd >= 0 || dirfd >= 0); } } } @@ -475,8 +476,8 @@ consider_visiting(FTS *p, FTSENT *ent) if (ent->fts_info == FTS_NSOK || ent->fts_info == FTS_NS /* e.g. symlink loop */) { - assert(!state.have_stat); - assert(!state.have_type); + assert (!state.have_stat); + assert (!state.have_type); state.type = mode = 0; } else diff --git a/find/parser.c b/find/parser.c index 275704a..dcc6643 100644 --- a/find/parser.c +++ b/find/parser.c @@ -56,6 +56,7 @@ */ /* We need for isatty(). */ #include +#include #if ENABLE_NLS # include @@ -372,8 +373,7 @@ get_stat_Ytime(const struct stat *p, *ret = get_stat_mtime(p); return 1; default: - assert(0); - abort(); + assert (0); abort(); } } @@ -1417,7 +1417,7 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr) char x, y; const char validchars[] = "aBcmt"; - assert(0 == strncmp("-newer", argv[*arg_ptr], 6)); + assert (0 == strncmp("-newer", argv[*arg_ptr], 6)); x = argv[*arg_ptr][6]; y = argv[*arg_ptr][7]; @@ -1465,8 +1465,8 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr) our_pred->args.reftime.xval = XVAL_MTIME; break; default: - assert(strchr(validchars, x)); - assert(0); + assert (strchr(validchars, x)); + assert (0); } if ('t' == y) @@ -1500,9 +1500,9 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr) our_pred->est_success_rate = estimate_timestamp_success_rate(our_pred->args.reftime.ts.tv_sec); (*arg_ptr)++; - assert(our_pred->pred_func != NULL); - assert(our_pred->pred_func == pred_newerXY); - assert(our_pred->need_stat); + assert (our_pred->pred_func != NULL); + assert (our_pred->pred_func == pred_newerXY); + assert (our_pred->need_stat); return true; } } @@ -2072,7 +2072,7 @@ parse_samefile (const struct parser_table* entry, char **argv, int *arg_ptr) { if (options.open_nofollow_available) { - assert(O_NOFOLLOW != 0); + assert (O_NOFOLLOW != 0); openflags |= O_NOFOLLOW; fd = -1; /* safe to open it. */ } @@ -2102,7 +2102,7 @@ parse_samefile (const struct parser_table* entry, char **argv, int *arg_ptr) fd = -1; /* safe to open it without O_NOFOLLOW */ } - assert(fd != -3); /* check we made a decision */ + assert (fd != -3); /* check we made a decision */ if (fd == -1) { /* Race condition here. The file might become a @@ -2743,8 +2743,8 @@ make_segment (struct segment **segment, { case KIND_PLAIN: /* Plain text string, no % conversion. */ case KIND_STOP: /* Terminate argument, no newline. */ - assert(0 == format_char); - assert(0 == aux_format_char); + assert (0 == format_char); + assert (0 == aux_format_char); *fmt = '\0'; if (mycost > pred->p_cost) pred->p_cost = NeedsNothing; @@ -2752,7 +2752,7 @@ make_segment (struct segment **segment, break; } - assert(kind == KIND_FORMAT); + assert (kind == KIND_FORMAT); switch (format_char) { case 'l': /* object of symlink */ diff --git a/find/pred.c b/find/pred.c index da4bfe1..d043d11 100644 --- a/find/pred.c +++ b/find/pred.c @@ -319,7 +319,7 @@ boolean pred_anewer (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr) { (void) &pathname; - assert(COMP_GT == pred_ptr->args.reftime.kind); + assert (COMP_GT == pred_ptr->args.reftime.kind); return compare_ts(get_stat_atime(stat_buf), pred_ptr->args.reftime.ts) > 0; } @@ -352,7 +352,7 @@ pred_cnewer (const char *pathname, struct stat *stat_buf, struct predicate *pred { (void) pathname; - assert(COMP_GT == pred_ptr->args.reftime.kind); + assert (COMP_GT == pred_ptr->args.reftime.kind); return compare_ts(get_stat_ctime(stat_buf), pred_ptr->args.reftime.ts) > 0; } @@ -1065,7 +1065,7 @@ pred_fprintf (const char *pathname, struct stat *stat_buf, struct predicate *pre valid = 1; break; default: - assert(0); + assert (0); abort (); } /* We trust the output of format_date not to contain @@ -1294,7 +1294,7 @@ pred_newer (const char *pathname, struct stat *stat_buf, struct predicate *pred_ { (void) pathname; - assert(COMP_GT == pred_ptr->args.reftime.kind); + assert (COMP_GT == pred_ptr->args.reftime.kind); return compare_ts(get_stat_mtime(stat_buf), pred_ptr->args.reftime.ts) > 0; } @@ -1304,12 +1304,12 @@ pred_newerXY (const char *pathname, struct stat *stat_buf, struct predicate *pre struct timespec ts; boolean collected = false; - assert(COMP_GT == pred_ptr->args.reftime.kind); + assert (COMP_GT == pred_ptr->args.reftime.kind); switch (pred_ptr->args.reftime.xval) { case XVAL_TIME: - assert(pred_ptr->args.reftime.xval != XVAL_TIME); + assert (pred_ptr->args.reftime.xval != XVAL_TIME); return false; case XVAL_ATIME: @@ -1340,7 +1340,7 @@ pred_newerXY (const char *pathname, struct stat *stat_buf, struct predicate *pre break; } - assert(collected); + assert (collected); return compare_ts(ts, pred_ptr->args.reftime.ts) > 0; } @@ -1667,7 +1667,7 @@ pred_type (const char *pathname, struct stat *stat_buf, struct predicate *pred_p mode_t mode; mode_t type = pred_ptr->args.type; - assert(state.have_type); + assert (state.have_type); if (0 == state.type) { @@ -1860,7 +1860,7 @@ prep_child_for_exec (boolean close_stdin, int dirfd) */ if (dirfd != AT_FDCWD) { - assert(dirfd >= 0); + assert (dirfd >= 0); if (0 != fchdir(dirfd)) { /* If we cannot execute our command in the correct directory, @@ -1886,8 +1886,8 @@ launch (const struct buildcmd_control *ctl, if (!execp->use_current_dir) { - assert(starting_desc >= 0); - assert(execp->dirfd == starting_desc); + assert (starting_desc >= 0); + assert (execp->dirfd == starting_desc); } @@ -1911,7 +1911,7 @@ launch (const struct buildcmd_control *ctl, if (child_pid == 0) { /* We are the child. */ - assert(starting_desc >= 0); + assert (starting_desc >= 0); if (!prep_child_for_exec(execp->close_stdin, execp->dirfd)) { _exit(1); @@ -2025,7 +2025,7 @@ format_date (struct timespec ts, int kind) * demonstrating that the performance difference is actually * measurable. */ - assert(sizeof(buf) >= LONGEST_HUMAN_READABLE); + assert (sizeof(buf) >= LONGEST_HUMAN_READABLE); charsprinted = 0; need_ns_suffix = 0; @@ -2067,7 +2067,7 @@ format_date (struct timespec ts, int kind) */ ns_buf[0] = 0; charsprinted = snprintf(ns_buf, NS_BUF_LEN, ".%09ld0", (long int)ts.tv_nsec); - assert(charsprinted < NS_BUF_LEN); + assert (charsprinted < NS_BUF_LEN); } if (kind != '@' @@ -2079,7 +2079,7 @@ format_date (struct timespec ts, int kind) */ if (need_ns_suffix) { - assert((sizeof buf - strlen(buf)) > strlen(ns_buf)); + assert ((sizeof buf - strlen(buf)) > strlen(ns_buf)); strcat(buf, ns_buf); } return buf; @@ -2094,8 +2094,8 @@ format_date (struct timespec ts, int kind) */ char *p = human_readable (ts.tv_sec < 0 ? -w : w, buf + 1, human_ceiling, 1, 1); - assert(p > buf); - assert(p < (buf + (sizeof buf))); + assert (p > buf); + assert (p < (buf + (sizeof buf))); if (ts.tv_sec < 0) *--p = '-'; /* XXX: Ugh, relying on internal details of human_readable(). */ @@ -2108,7 +2108,7 @@ format_date (struct timespec ts, int kind) { len = strlen(p); used = (p-buf) + len; /* Offset into buf of current end */ - assert(sizeof buf > used); /* Ensure we can perform subtraction safely. */ + assert (sizeof buf > used); /* Ensure we can perform subtraction safely. */ remaining = sizeof buf - used - 1u; /* allow space for NUL */ if (strlen(ns_buf) >= remaining) @@ -2117,7 +2117,7 @@ format_date (struct timespec ts, int kind) "charsprinted=%ld but remaining=%lu: ns_buf=%s", (long)charsprinted, (unsigned long)remaining, ns_buf); } - assert(strlen(ns_buf) < remaining); + assert (strlen(ns_buf) < remaining); strcat(p, ns_buf); } return p; @@ -2146,14 +2146,14 @@ ctime_format (struct timespec ts) ptm = localtime(&ts.tv_sec); if (ptm) { - assert(ptm->tm_wday >= 0); - assert(ptm->tm_wday < 7); - assert(ptm->tm_mon >= 0); - assert(ptm->tm_mon < 12); - assert(ptm->tm_hour >= 0); - assert(ptm->tm_hour < 24); - assert(ptm->tm_min < 60); - assert(ptm->tm_sec <= 61); /* allows 2 leap seconds. */ + assert (ptm->tm_wday >= 0); + assert (ptm->tm_wday < 7); + assert (ptm->tm_mon >= 0); + assert (ptm->tm_mon < 12); + assert (ptm->tm_hour >= 0); + assert (ptm->tm_hour < 24); + assert (ptm->tm_min < 60); + assert (ptm->tm_sec <= 61); /* allows 2 leap seconds. */ /* wkday mon mday hh:mm:ss.nnnnnnnnn yyyy */ nout = snprintf(resultbuf, TIME_BUF_LEN, @@ -2167,7 +2167,7 @@ ctime_format (struct timespec ts) (long int)ts.tv_nsec, 1900 + ptm->tm_year); - assert(nout < TIME_BUF_LEN); + assert (nout < TIME_BUF_LEN); return resultbuf; } else @@ -2294,7 +2294,7 @@ void show_success_rates(const struct predicate *p) void pred_sanity_check(const struct predicate *predicates) { - /* Do nothing, since assert() is a no-op with _NDEBUG set */ + /* Do nothing, since assert is a no-op with _NDEBUG set */ return; } #else @@ -2306,10 +2306,10 @@ pred_sanity_check(const struct predicate *predicates) for (p=predicates; p != NULL; p=p->pred_next) { /* All predicates must do something. */ - assert(p->pred_func != NULL); + assert (p->pred_func != NULL); /* All predicates must have a parser table entry. */ - assert(p->parser_entry != NULL); + assert (p->parser_entry != NULL); /* If the parser table tells us that just one predicate function is * possible, verify that that is still the one that is in effect. @@ -2318,7 +2318,7 @@ pred_sanity_check(const struct predicate *predicates) */ if (p->parser_entry->pred_func) { - assert(p->parser_entry->pred_func == p->pred_func); + assert (p->parser_entry->pred_func == p->pred_func); } switch (p->parser_entry->type) @@ -2334,8 +2334,8 @@ pred_sanity_check(const struct predicate *predicates) */ case ARG_OPTION: case ARG_POSITIONAL_OPTION: - assert(p->parser_entry->type != ARG_OPTION); - assert(p->parser_entry->type != ARG_POSITIONAL_OPTION); + assert (p->parser_entry->type != ARG_OPTION); + assert (p->parser_entry->type != ARG_POSITIONAL_OPTION); break; case ARG_ACTION: @@ -2345,7 +2345,7 @@ pred_sanity_check(const struct predicate *predicates) /* actions other than -prune and -quit should * inhibit the default -print */ - assert(p->no_default_print); + assert (p->no_default_print); } break; @@ -2359,8 +2359,8 @@ pred_sanity_check(const struct predicate *predicates) /* Punctuation and tests should have no side * effects and not inhibit default print. */ - assert(!p->no_default_print); - assert(!p->side_effects); + assert (!p->no_default_print); + assert (!p->side_effects); break; } } diff --git a/find/tree.c b/find/tree.c index b76cfec..66414fe 100644 --- a/find/tree.c +++ b/find/tree.c @@ -971,13 +971,7 @@ check_sorted(void *base, size_t members, size_t membersize, if (result < 0) return false; result = cmpfn(p+(i-1)*membersize, p+i*membersize); - assert(result <= 0); - } - for (i=1u; ifn <= pl2->fn); + assert (result <= 0); } return true; } @@ -988,11 +982,16 @@ cost_table_comparison(const void *p1, const void *p2) { const struct pred_cost_lookup *pc1 = p1; const struct pred_cost_lookup *pc2 = p2; - - + const void* pf1 = (const void*)pc1->fn; + const void* pf2 = (const void*)pc2->fn; + + /* We use casts to void* for > comparison because not all C + * compilers allow order comparison between functions. For example, + * that would fail on DEC Alpha OSF/1 with native cc. + */ if (pc1->fn == pc2->fn) return 0; - else if (pc1->fn > pc2->fn) + else if (pf1 > pf2) return 1; else return -1; @@ -1103,32 +1102,32 @@ getrate(const struct predicate *p) float calculate_derived_rates(struct predicate *p) { - assert(NULL != p); + assert (NULL != p); if (p->pred_right) calculate_derived_rates(p->pred_right); if (p->pred_left) calculate_derived_rates(p->pred_left); - assert(p->p_type != CLOSE_PAREN); - assert(p->p_type != OPEN_PAREN); + assert (p->p_type != CLOSE_PAREN); + assert (p->p_type != OPEN_PAREN); switch (p->p_type) { case NO_TYPE: - assert(NULL == p->pred_right); - assert(NULL == p->pred_left); + assert (NULL == p->pred_right); + assert (NULL == p->pred_left); return p->est_success_rate; case PRIMARY_TYPE: - assert(NULL == p->pred_right); - assert(NULL == p->pred_left); + assert (NULL == p->pred_right); + assert (NULL == p->pred_left); return p->est_success_rate; case UNI_OP: /* Unary operators must have exactly one operand */ - assert(pred_is(p, pred_negate)); - assert(NULL == p->pred_left); + assert (pred_is(p, pred_negate)); + assert (NULL == p->pred_left); p->est_success_rate = (1.0 - p->pred_right->est_success_rate); return p->est_success_rate; @@ -1151,8 +1150,8 @@ calculate_derived_rates(struct predicate *p) else { /* only and, or and comma are BI_OP. */ - assert(0); - rate = 0.0f; + assert (0); + abort (); } p->est_success_rate = constrain_rate(rate); } @@ -1174,12 +1173,12 @@ static void check_normalization(struct predicate *p, boolean at_root) { if (at_root) { - assert(BI_OP == p->p_type); + assert (BI_OP == p->p_type); } if (p->pred_left) { - assert(BI_OP == p->pred_left->p_type); + assert (BI_OP == p->pred_left->p_type); check_normalization(p->pred_left, false); } if (p->pred_right) @@ -1212,9 +1211,9 @@ build_expression_tree(int argc, char *argv[], int end_of_leading_options) entry_open = find_parser("("); entry_close = find_parser(")"); entry_print = find_parser("print"); - assert(entry_open != NULL); - assert(entry_close != NULL); - assert(entry_print != NULL); + assert (entry_open != NULL); + assert (entry_close != NULL); + assert (entry_print != NULL); parse_openparen (entry_open, argv, &argc); last_pred->p_name = "("; @@ -1410,8 +1409,8 @@ get_new_pred (const struct parser_table *entry) (void) entry; /* Options should not be turned into predicates. */ - assert(entry->type != ARG_OPTION); - assert(entry->type != ARG_POSITIONAL_OPTION); + assert (entry->type != ARG_OPTION); + assert (entry->type != ARG_POSITIONAL_OPTION); if (predicates == NULL) { @@ -1460,7 +1459,7 @@ get_new_pred_chk_op (const struct parser_table *entry) entry_and = find_parser("and"); /* Check that it's actually there. If not, that is a bug.*/ - assert(entry_and != NULL); + assert (entry_and != NULL); if (last_pred) switch (last_pred->p_type) diff --git a/find/util.c b/find/util.c index 9c14205..c1f285e 100644 --- a/find/util.c +++ b/find/util.c @@ -125,7 +125,7 @@ insert_primary_withpred (const struct parser_table *entry, PRED_FUNC pred_func) struct predicate * insert_primary (const struct parser_table *entry) { - assert(entry->pred_func != NULL); + assert (entry->pred_func != NULL); return insert_primary_withpred(entry, entry->pred_func); } @@ -299,7 +299,7 @@ do_complete_pending_execdirs(struct predicate *p, int dirfd) if (NULL == p) return; - assert(state.execdirs_outstanding); + assert (state.execdirs_outstanding); do_complete_pending_execdirs(p->pred_left, dirfd); @@ -524,7 +524,7 @@ int optionh_stat(const char *name, struct stat *p) { if (AT_FDCWD != state.cwd_dir_fd) - assert(state.cwd_dir_fd >= 0); + assert (state.cwd_dir_fd >= 0); set_stat_placeholders(p); if (0 == state.curdepth) { @@ -555,7 +555,7 @@ optionl_stat(const char *name, struct stat *p) { int rv; if (AT_FDCWD != state.cwd_dir_fd) - assert(state.cwd_dir_fd >= 0); + assert (state.cwd_dir_fd >= 0); set_stat_placeholders(p); rv = fstatat(state.cwd_dir_fd, name, p, 0); @@ -572,7 +572,7 @@ optionl_stat(const char *name, struct stat *p) int optionp_stat(const char *name, struct stat *p) { - assert((state.cwd_dir_fd >= 0) || (state.cwd_dir_fd==AT_FDCWD)); + assert ((state.cwd_dir_fd >= 0) || (state.cwd_dir_fd==AT_FDCWD)); set_stat_placeholders(p); return fstatat(state.cwd_dir_fd, name, p, AT_SYMLINK_NOFOLLOW); } @@ -596,7 +596,7 @@ debug_stat (const char *file, struct stat *bufp) return optionp_stat(file, bufp); } /*NOTREACHED*/ - assert(false); + assert (0); return -1; } @@ -885,7 +885,7 @@ now(void) return retval; } t = time(NULL); - assert(t != (time_t)-1); + assert (t != (time_t)-1); retval.tv_sec = t; retval.tv_nsec = 0; return retval; diff --git a/lib/buildcmd.c b/lib/buildcmd.c index 77108c2..fba3cf6 100644 --- a/lib/buildcmd.c +++ b/lib/buildcmd.c @@ -390,7 +390,7 @@ bc_get_arg_max(void) /* We may resort to using LONG_MAX, so check it fits. */ /* XXX: better to do a compile-time check */ - assert( (~(size_t)0) >= LONG_MAX); + assert ( (~(size_t)0) >= LONG_MAX); #ifdef _SC_ARG_MAX val = sysconf(_SC_ARG_MAX); @@ -483,7 +483,7 @@ bc_init_controlinfo(struct buildcmd_control *ctl, /* need to subtract 2 on the following line - for Linux/PPC */ ctl->max_arg_count = (ctl->posix_arg_size_max / sizeof(char*)) - 2u; - assert(ctl->max_arg_count > 0); + assert (ctl->max_arg_count > 0); ctl->rplen = 0u; ctl->replace_pat = NULL; ctl->initial_argc = 0; @@ -531,7 +531,7 @@ bc_init_state(const struct buildcmd_control *ctl, * LONG_MAX. Adding one to it is safe though because earlier we * subtracted 2048. */ - assert(ctl->arg_max <= (LONG_MAX - 2048L)); + assert (ctl->arg_max <= (LONG_MAX - 2048L)); state->argbuf = xmalloc (ctl->arg_max + 1u); state->cmd_argv_chars = state->cmd_initial_argv_chars = 0; diff --git a/lib/buildcmd.h b/lib/buildcmd.h index c6f2373..6beb7f6 100644 --- a/lib/buildcmd.h +++ b/lib/buildcmd.h @@ -103,7 +103,7 @@ enum BC_INIT_STATUS { BC_INIT_OK = 0, BC_INIT_ENV_TOO_BIG, - BC_INIT_CANNOT_ACCOMODATE_HEADROOM, + BC_INIT_CANNOT_ACCOMODATE_HEADROOM }; extern size_t bc_size_of_environment (void); diff --git a/lib/extendbuf.c b/lib/extendbuf.c index 079e6b7..7ff674c 100644 --- a/lib/extendbuf.c +++ b/lib/extendbuf.c @@ -66,7 +66,7 @@ extendbuf(void* existing, size_t wanted, size_t *allocated) saved_errno = errno; - assert(wanted > 0u); + assert (wanted > 0u); newsize = decide_size(*allocated, wanted); if ( (*allocated) == 0 ) @@ -74,7 +74,7 @@ extendbuf(void* existing, size_t wanted, size_t *allocated) /* Sanity check: If there is no existing allocation size, there * must be no existing allocated buffer. */ - assert(NULL == existing); + assert (NULL == existing); (*allocated) = newsize; result = xmalloc(newsize); diff --git a/locate/frcode.c b/locate/frcode.c index e4daec1..c5bc25d 100644 --- a/locate/frcode.c +++ b/locate/frcode.c @@ -127,8 +127,8 @@ put_short (int c, FILE *fp) * indicates that the result of shifting a negative value right is * implementation defined. */ - assert(c <= SHRT_MAX); - assert(c >= SHRT_MIN); + assert (c <= SHRT_MAX); + assert (c >= SHRT_MIN); return (putc (c >> 8, fp) != EOF) && (putc (c, fp) != EOF); } diff --git a/locate/locate.c b/locate/locate.c index ae26de1..5bd28f0 100644 --- a/locate/locate.c +++ b/locate/locate.c @@ -1187,10 +1187,10 @@ search_one_database (int argc, int i; nread += nread2; + extend (&procdata, 256u, 0u); /* Read the list of the most common bigrams in the database. */ if (nread < 256) { - extend (&procdata, 256u, 0u); int more_read = fread (procdata.original_filename + nread, 1, 256 - nread, procdata.fp); if ( (more_read + nread) != 256 ) diff --git a/locate/word_io.c b/locate/word_io.c index c921ed5..275cd08 100644 --- a/locate/word_io.c +++ b/locate/word_io.c @@ -162,7 +162,7 @@ putword (FILE *fp, int word, /* You must decide before calling this function which * endianness you want to use. */ - assert(endian_state_flag != GetwordEndianStateInitial); + assert (endian_state_flag != GetwordEndianStateInitial); if (GetwordEndianStateSwab == endian_state_flag) { word = bswap_32(word); diff --git a/xargs/xargs.c b/xargs/xargs.c index 2a1e9a3..e9b81cd 100644 --- a/xargs/xargs.c +++ b/xargs/xargs.c @@ -281,7 +281,7 @@ get_char_oct_or_hex_escape(const char *s) unsigned long val; char *endp; - assert('\\' == s[0]); + assert ('\\' == s[0]); if ('x' == s[1]) { @@ -470,17 +470,17 @@ main (int argc, char **argv) /* Note that val can in fact be greater than ARG_MAX * and bc_ctl.arg_max can also be greater than ARG_MAX. */ - assert(bc_ctl.arg_max <= (val-XARGS_POSIX_HEADROOM)); + assert (bc_ctl.arg_max <= (val-XARGS_POSIX_HEADROOM)); } else { # if defined ARG_MAX - assert(bc_ctl.arg_max <= (ARG_MAX-XARGS_POSIX_HEADROOM)); + assert (bc_ctl.arg_max <= (ARG_MAX-XARGS_POSIX_HEADROOM)); # endif } #else /* No _SC_ARG_MAX */ - assert(bc_ctl.arg_max <= (ARG_MAX-XARGS_POSIX_HEADROOM)); + assert (bc_ctl.arg_max <= (ARG_MAX-XARGS_POSIX_HEADROOM)); #endif @@ -489,7 +489,7 @@ main (int argc, char **argv) * conforms to the POSIX requirement that the default command * line length shall be at least LINE_MAX. */ - assert(bc_ctl.arg_max >= LINE_MAX); + assert (bc_ctl.arg_max >= LINE_MAX); #endif bc_ctl.exec_callback = xargs_do_exec; @@ -636,7 +636,7 @@ main (int argc, char **argv) * the environment is too large. */ act_on_init_result(); - assert(BC_INIT_OK == bcstatus); + assert (BC_INIT_OK == bcstatus); if (0 == strcmp (input_file, "-")) { @@ -679,7 +679,7 @@ main (int argc, char **argv) /* Without SIZE_MAX (i.e. limits.h) this is probably * close to the best we can do. */ - assert(sizeof(size_t) <= sizeof(unsigned long)); + assert (sizeof(size_t) <= sizeof(unsigned long)); #endif if (show_limits) -- 2.11.4.GIT