shred: placate coverity and fix a comment
authorJim Meyering <meyering@redhat.com>
Wed, 25 May 2011 19:35:50 +0000 (21:35 +0200)
committerJim Meyering <meyering@redhat.com>
Thu, 26 May 2011 20:10:46 +0000 (22:10 +0200)
* src/shred.c (incname): Add an assertion to tell static analyzers
that we know this particular use of strchr never returns NULL.
Finish incomplete sentence in function-describing comment.

src/shred.c

index d8b33e7..ecb27b8 100644 (file)
@@ -907,9 +907,9 @@ static char const nameset[] =
 "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.";
 
 /* Increment NAME (with LEN bytes).  NAME must be a big-endian base N
-   number with the digits taken from nameset.  Return true if
-   successful if not (because NAME already has the greatest possible
-   value.  */
+   number with the digits taken from nameset.  Return true if successful.
+   Otherwise, (because NAME already has the greatest possible value)
+   return false.  */
 
 static bool
 incname (char *name, size_t len)
@@ -918,6 +918,10 @@ incname (char *name, size_t len)
     {
       char const *p = strchr (nameset, name[len]);
 
+      /* Given that NAME is composed of bytes from NAMESET,
+         P will never be NULL here.  */
+      assert (p);
+
       /* If this character has a successor, use it.  */
       if (p[1])
         {