]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
[COVERITY] Allow blkid_dev_has_tag to check if a tag exists when value==NULL
authorTheodore Ts'o <tytso@mit.edu>
Sun, 18 Mar 2007 15:21:44 +0000 (11:21 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 18 Mar 2007 15:21:44 +0000 (11:21 -0400)
blkid_dev_has_tag() will immediately return -1 (an error if value is
NULL.  Thus at the test later on value cannot be NULL. There are two
possible ways to go about fixing this. The first would be to remove the
first NULL check for value.  The second one would be to remove the
second check (and the deadcode).

I chose the second path because the functionality added is something
which a programmer could reasonably expect given the function name, and
it is highly unlikely any existing code is depending on the fact that
blkid_dev_has_tag() will return an error if value is NULL.

Coverity ID: 3: Deadcode

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/blkid/ChangeLog
lib/blkid/tag.c

index a0890a2a2913706f7c79c7ab88984bd87eec934b..3e95a7278cf241b60728bd10a956d9a5740f0d79 100644 (file)
@@ -1,3 +1,9 @@
+2007-03-18  Theodore Tso  <tytso@mit.edu>
+
+       * tag.c (blkid_dev_has_tag): Allow value to be NULL, in which case
+               blkid_dev_has_tag() will return TRUE if the passed-in tag
+               exists --- reasonable functionality given the function name.
+
 2007-03-06  Theodore Tso  <tytso@mit.edu>
 
        * devname.c (dm_probe_all), probe.c (blkid_verify): Fix memory
index a3c13b80207c679b8c7df68995a2cc283e232c43..c4e5c8219394fb92be854bbd5ade8e7db325fc96 100644 (file)
@@ -87,12 +87,12 @@ extern int blkid_dev_has_tag(blkid_dev dev, const char *type,
 {
        blkid_tag               tag;
 
-       if (!dev || !type || !value)
+       if (!dev || !type)
                return -1;
 
        tag = blkid_find_tag_dev(dev, type);
        if (!value)
-               return(tag != NULL);
+               return (tag != NULL);
        if (!tag || strcmp(tag->bit_val, value))
                return 0;
        return 1;