[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-idutils] [PATCH 5/9] build: work around new warning/suggestion to u
From: |
Jim Meyering |
Subject: |
[bug-idutils] [PATCH 5/9] build: work around new warning/suggestion to use "pure" |
Date: |
Thu, 2 Feb 2012 08:38:44 +0100 |
From: Jim Meyering <address@hidden>
* src/mkid.c (check_hits): Change semantics to avoid the warning
that this assert-containing function could be declared with the
"pure" attribute. Instead, return 0/1, declare "pure" and let
the caller perform the assertion. Rename from assert_hits.
Add a comment.
---
src/mkid.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/mkid.c b/src/mkid.c
index 082395e..0c882f2 100644
--- a/src/mkid.c
+++ b/src/mkid.c
@@ -86,7 +86,7 @@ static int count_vec_size (struct summary *summary,
unsigned char const *tail_hits);
static int count_buf_size (struct summary *summary,
unsigned char const *tail_hits);
-static void assert_hits (struct summary* summary);
+static int check_hits (struct summary* summary) _GL_ATTRIBUTE_PURE;
static void write_hits (FILE *fp, struct summary *summary,
unsigned char const *tail_hits);
static void sign_token (struct token *token);
@@ -764,7 +764,7 @@ write_id_file (struct idhead *idhp)
putc ('\0', idhp->idh_FILE);
putc ('\0', idhp->idh_FILE);
}
- assert_hits (summary_root);
+ assert (check_hits (summary_root) == 0);
idhp->idh_tokens = token_table.ht_fill;
off = ftello (idhp->idh_FILE);
if (UINT32_MAX < off)
@@ -983,19 +983,25 @@ count_buf_size (struct summary *summary, unsigned char
const *tail_hits)
}
}
-static void
-assert_hits (struct summary* summary)
+/* Sanity-check hit counts. Return nonzero if there's a problem.
+ Otherwise, return 0. */
+static int
+check_hits (struct summary* summary)
{
struct summary **kids = summary->sum_kids;
struct summary **end = &kids[8];
- assert (summary->sum_hits == NULL || *summary->sum_hits == 0);
+ if ( ! (summary->sum_hits == NULL || *summary->sum_hits == 0))
+ return 1;
if (end[-1] == 0)
while (*--end == 0)
;
while (kids < end)
- assert_hits (*kids++);
+ if (check_hits (*kids++))
+ return 1;
+
+ return 0;
}
static void
--
1.7.9.49.g25388
- [bug-idutils] build/gnulib adjustments, Jim Meyering, 2012/02/02
- [bug-idutils] [PATCH 1/9] tests: disable gnulib's get-rusage-as test, Jim Meyering, 2012/02/02
- [bug-idutils] [PATCH 3/9] build: turn off two of gcc's warning options, Jim Meyering, 2012/02/02
- [bug-idutils] [PATCH 5/9] build: work around new warning/suggestion to use "pure",
Jim Meyering <=
- [bug-idutils] [PATCH 2/9] build: fix man-page-building and cross-check rules, Jim Meyering, 2012/02/02
- [bug-idutils] [PATCH 4/9] build: add const and pure attributes, per gcc recommendation, Jim Meyering, 2012/02/02
- [bug-idutils] [PATCH 7/9] maint: make copyright statements more consistent; update gnulib, Jim Meyering, 2012/02/02
- [bug-idutils] [PATCH 6/9] build: update bootstrap from gnulib, and adapt, Jim Meyering, 2012/02/02
- [bug-idutils] [PATCH 8/9] tests: adapt framework for upcoming automake-1.12, Jim Meyering, 2012/02/02
- [bug-idutils] [PATCH 9/9] maint: use gnulib's readme-release module, Jim Meyering, 2012/02/02