Skip to content

Commit

Permalink
libadf: silence false-positive clang static analyzer warnings
Browse files Browse the repository at this point in the history
clang warns about leaks when adf_find_nodes() takes an error-recovery
path and returns ret >= 0.  This is only possible if readdir() or
sscanf() set errno <= 0 on error, which POSIX says can't happen.

Bug: 27125399

Change-Id: I57ea312419efcac01f5721d07fc578a298bce2ea
Signed-off-by: Greg Hackmann <[email protected]>
  • Loading branch information
greghackmann authored and spezi77 committed Mar 25, 2016
1 parent e16e82f commit 897a898
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion adf/libadf/adf.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ static ssize_t adf_find_nodes(const char *pattern, adf_id_t **ids)

if (matched < 0) {
ret = -errno;
#if __clang_analyzer__
if (ret >= 0)
__builtin_unreachable();
#endif
goto done;
} else if (matched != 1) {
continue;
Expand All @@ -65,8 +69,13 @@ static ssize_t adf_find_nodes(const char *pattern, adf_id_t **ids)
ids_ret[n] = id;
n++;
}
if (errno)
if (errno) {
ret = -errno;
#if __clang_analyzer__
if (ret >= 0)
__builtin_unreachable();
#endif
}
else
ret = n;

Expand Down

0 comments on commit 897a898

Please sign in to comment.