libmount: make mnt_table_find_* more robust [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2013-03-27 16:47:46 +01:00
parent 05ba8c8483
commit 4cd271adc1
1 changed files with 14 additions and 0 deletions

View File

@ -444,6 +444,8 @@ struct libmnt_fs *mnt_table_find_mountpoint(struct libmnt_table *tb,
if (!tb || !path)
return NULL;
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup MOUNTPOINT: %s", path));
@ -494,6 +496,8 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat
if (!tb || !path)
return NULL;
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup TARGET: %s", path));
@ -564,6 +568,8 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa
assert(tb);
if (!tb || !path)
return NULL;
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup srcpath: %s", path));
@ -668,6 +674,8 @@ struct libmnt_fs *mnt_table_find_tag(struct libmnt_table *tb, const char *tag,
if (!tb || !tag || !val)
return NULL;
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup by TAG: %s %s", tag, val));
@ -710,6 +718,8 @@ struct libmnt_fs *mnt_table_find_source(struct libmnt_table *tb,
if (!tb)
return NULL;
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup SOURCE: %s", source));
@ -753,6 +763,8 @@ struct libmnt_fs *mnt_table_find_pair(struct libmnt_table *tb, const char *sourc
if (!tb || !target)
return NULL;
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup SOURCE: %s TARGET: %s", source, target));
@ -788,6 +800,8 @@ struct libmnt_fs *mnt_table_find_devno(struct libmnt_table *tb,
if (!tb)
return NULL;
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup DEVNO: %d", (int) devno));