e = realloc(cache->ents, sz * sizeof(struct mnt_cache_entry));
if (!e)
- return -1;
+ return -ENOMEM;
cache->ents = e;
cache->nallocs = sz;
}
{
size_t tksz, vlsz;
char *native;
+ int rc;
assert(cache);
assert(real);
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;
}
* 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)
{
assert(devname);
if (!cache || !devname)
- return -1;
+ return -EINVAL;
DBG(DEBUG_CACHE, printf("cache: tags for %s requested\n", devname));
cache = mnt_new_cache();
if (!cache)
- return -1;
+ return -ENOMEM;
while(fgets(line, sizeof(line), stdin)) {
size_t sz = strlen(line);
cache = mnt_new_cache();
if (!cache)
- return -1;
+ return -ENOMEM;
while(fgets(line, sizeof(line), stdin)) {
size_t sz = strlen(line);
cache = mnt_new_cache();
if (!cache)
- return -1;
+ return -ENOMEM;
while(fgets(line, sizeof(line), stdin)) {
size_t sz = strlen(line);
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);