From: Theodore Ts'o Date: Sun, 18 Mar 2007 15:21:44 +0000 (-0400) Subject: [COVERITY] Allow blkid_dev_has_tag to check if a tag exists when value==NULL X-Git-Tag: E2FSPROGS-1_40~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d90be5b1437b839e5f1afcee7073798d833e4534;p=thirdparty%2Fe2fsprogs.git [COVERITY] Allow blkid_dev_has_tag to check if a tag exists when value==NULL 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" --- diff --git a/lib/blkid/ChangeLog b/lib/blkid/ChangeLog index a0890a2a2..3e95a7278 100644 --- a/lib/blkid/ChangeLog +++ b/lib/blkid/ChangeLog @@ -1,3 +1,9 @@ +2007-03-18 Theodore Tso + + * 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 * devname.c (dm_probe_all), probe.c (blkid_verify): Fix memory diff --git a/lib/blkid/tag.c b/lib/blkid/tag.c index a3c13b802..c4e5c8219 100644 --- a/lib/blkid/tag.c +++ b/lib/blkid/tag.c @@ -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;