]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
blob_get_name_by_id(): Treat id of dummy row as invalid.
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 26 Mar 2016 22:28:27 +0000 (22:28 +0000)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 3 May 2016 23:00:34 +0000 (01:00 +0200)
If the given id equals the id of the dummy row, the function currently
returns an empty object. This is unfortunate, since blob table users
should not know about the dummy row implementation detail. This patch
makes the function return -E_DUMMY_ROW instead.

In error.h, the E_DUMMY_ROW error code was defined in the section
for mood.c because this file contains the only user of the error
code. With another user in blob.c it seems appropriate to move it to
the blob section instead.

blob.c
error.h

diff --git a/blob.c b/blob.c
index 2e0a4762bfd1e34d0f12c7a9b2d4de582c8316d4..ca39de0db5fc8fdb15009d0ed1c46ec14ca15087 100644 (file)
--- a/blob.c
+++ b/blob.c
@@ -496,6 +496,8 @@ static int blob_get_name_by_id(struct osl_table *table, uint32_t id,
        ret = osl(osl_get_object(table, row, BLOBCOL_NAME, &obj));
        if (ret < 0)
                return ret;
        ret = osl(osl_get_object(table, row, BLOBCOL_NAME, &obj));
        if (ret < 0)
                return ret;
+       if (*(char *)obj.data == '\0')
+               return -E_DUMMY_ROW;
        *name = (char *)obj.data;
        return 1;
 }
        *name = (char *)obj.data;
        return 1;
 }
diff --git a/error.h b/error.h
index b735233339f1b64a89697e318db36436a907e091..830d0f8d186560522b93dd89d51065ee4d4119e2 100644 (file)
--- a/error.h
+++ b/error.h
@@ -246,7 +246,6 @@ extern const char **para_errlist[];
 
 #define MOOD_ERRORS \
        PARA_ERROR(NO_MOOD, "no mood available"), \
 
 #define MOOD_ERRORS \
        PARA_ERROR(NO_MOOD, "no mood available"), \
-       PARA_ERROR(DUMMY_ROW, "attempted to access blob dummy object"), \
 
 
 #define MM_ERRORS \
 
 
 #define MM_ERRORS \
@@ -261,6 +260,7 @@ extern const char **para_errlist[];
 
 #define BLOB_ERRORS \
        PARA_ERROR(BLOB_SYNTAX, "blob syntax error"), \
 
 #define BLOB_ERRORS \
        PARA_ERROR(BLOB_SYNTAX, "blob syntax error"), \
+       PARA_ERROR(DUMMY_ROW, "attempted to access blob dummy object"), \
 
 
 #define PLAYLIST_ERRORS \
 
 
 #define PLAYLIST_ERRORS \