summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shlibs/mount/src/cache.c25
-rw-r--r--shlibs/mount/src/lock.c2
-rw-r--r--shlibs/mount/src/mountP.h1
-rw-r--r--shlibs/mount/src/optstr.c4
-rw-r--r--shlibs/mount/src/test.c2
5 files changed, 18 insertions, 16 deletions
diff --git a/shlibs/mount/src/cache.c b/shlibs/mount/src/cache.c
index 027fda44f..7e5c4afeb 100644
--- a/shlibs/mount/src/cache.c
+++ b/shlibs/mount/src/cache.c
@@ -111,7 +111,7 @@ static int mnt_cache_add_entry(mnt_cache *cache, char *native,
e = realloc(cache->ents, sz * sizeof(struct mnt_cache_entry));
if (!e)
- return -1;
+ return -ENOMEM;
cache->ents = e;
cache->nallocs = sz;
}
@@ -136,6 +136,7 @@ static int mnt_cache_add_tag(mnt_cache *cache, const char *token,
{
size_t tksz, vlsz;
char *native;
+ int rc;
assert(cache);
assert(real);
@@ -151,17 +152,17 @@ static int mnt_cache_add_tag(mnt_cache *cache, const char *token,
native = malloc(tksz + vlsz + 2);
if (!native)
- goto error;
+ return -ENOMEM;
memcpy(native, token, tksz + 1); /* include '\0' */
memcpy(native + tksz + 1, value, vlsz + 1);
- if (mnt_cache_add_entry(cache, native, real, flag | MNT_CACHE_ISTAG))
- goto error;
- return 0;
-error:
+ rc = mnt_cache_add_entry(cache, native, real, flag | MNT_CACHE_ISTAG);
+ if (!rc)
+ return 0;
+
free(native);
- return -1;
+ return rc;
}
@@ -234,7 +235,7 @@ const char *mnt_cache_find_tag(mnt_cache *cache,
* Reads @devname LABEL and UUID to the @cache.
*
* Returns: 0 if at least one tag was added, 1 if no tag was added or
- * -1 in case of error.
+ * negative number in case of error.
*/
int mnt_cache_read_tags(mnt_cache *cache, const char *devname)
{
@@ -246,7 +247,7 @@ int mnt_cache_read_tags(mnt_cache *cache, const char *devname)
assert(devname);
if (!cache || !devname)
- return -1;
+ return -EINVAL;
DBG(DEBUG_CACHE, printf("cache: tags for %s requested\n", devname));
@@ -477,7 +478,7 @@ int test_resolve_path(struct mtest *ts, int argc, char *argv[])
cache = mnt_new_cache();
if (!cache)
- return -1;
+ return -ENOMEM;
while(fgets(line, sizeof(line), stdin)) {
size_t sz = strlen(line);
@@ -500,7 +501,7 @@ int test_resolve_spec(struct mtest *ts, int argc, char *argv[])
cache = mnt_new_cache();
if (!cache)
- return -1;
+ return -ENOMEM;
while(fgets(line, sizeof(line), stdin)) {
size_t sz = strlen(line);
@@ -523,7 +524,7 @@ int test_read_tags(struct mtest *ts, int argc, char *argv[])
cache = mnt_new_cache();
if (!cache)
- return -1;
+ return -ENOMEM;
while(fgets(line, sizeof(line), stdin)) {
size_t sz = strlen(line);
diff --git a/shlibs/mount/src/lock.c b/shlibs/mount/src/lock.c
index beea23980..9d2718286 100644
--- a/shlibs/mount/src/lock.c
+++ b/shlibs/mount/src/lock.c
@@ -505,7 +505,7 @@ int test_lock(struct mtest *ts, int argc, char *argv[])
if (!lock)
return -1;
- if (mnt_lock_file(lock) == -1) {
+ if (mnt_lock_file(lock) != 0) {
fprintf(stderr, "%d: failed to lock %s file\n",
getpid(), datafile);
return -1;
diff --git a/shlibs/mount/src/mountP.h b/shlibs/mount/src/mountP.h
index d962b6796..444d0d776 100644
--- a/shlibs/mount/src/mountP.h
+++ b/shlibs/mount/src/mountP.h
@@ -11,6 +11,7 @@
#define _LIBMOUNT_PRIVATE_H
#include <sys/types.h>
+#include <errno.h>
#include "c.h"
#define USE_UNSTABLE_LIBMOUNT_API
diff --git a/shlibs/mount/src/optstr.c b/shlibs/mount/src/optstr.c
index 853f5f9b0..ffa93f20a 100644
--- a/shlibs/mount/src/optstr.c
+++ b/shlibs/mount/src/optstr.c
@@ -279,9 +279,9 @@ int mnt_optstr_set_option(char **optstr, const char *name, const char *value)
if (*optstr)
rc = mnt_optstr_locate_option(*optstr, name,
&begin, &end, &val, &valsz);
- if (rc == -1)
+ if (rc < 0)
/* parse error */
- return -1;
+ return rc;
if (rc == 1)
/* not found */
return mnt_optstr_append_option(optstr, name, value);
diff --git a/shlibs/mount/src/test.c b/shlibs/mount/src/test.c
index eb4f2d1d0..ac2ab1751 100644
--- a/shlibs/mount/src/test.c
+++ b/shlibs/mount/src/test.c
@@ -42,7 +42,7 @@ int mnt_run_test(struct mtest *tests, int argc, char *argv[])
}
}
- if (rc == -1 && ts->name == NULL)
+ if (rc < 0 && ts->name == NULL)
goto usage;
return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE;