From: Andre Noll Date: Sat, 26 Mar 2016 22:28:27 +0000 (+0000) Subject: blob_get_name_by_id(): Treat id of dummy row as invalid. X-Git-Tag: v0.5.6~35 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=7c007561e7031f5e33b91a8baf51bb952693a2d0;ds=sidebyside blob_get_name_by_id(): Treat id of dummy row as invalid. 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. --- diff --git a/blob.c b/blob.c index 2e0a4762..ca39de0d 100644 --- 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; + if (*(char *)obj.data == '\0') + return -E_DUMMY_ROW; *name = (char *)obj.data; return 1; } diff --git a/error.h b/error.h index b7352333..830d0f8d 100644 --- 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"), \ - PARA_ERROR(DUMMY_ROW, "attempted to access blob dummy object"), \ #define MM_ERRORS \ @@ -261,6 +260,7 @@ extern const char **para_errlist[]; #define BLOB_ERRORS \ PARA_ERROR(BLOB_SYNTAX, "blob syntax error"), \ + PARA_ERROR(DUMMY_ROW, "attempted to access blob dummy object"), \ #define PLAYLIST_ERRORS \