From: Michael Tremer Date: Mon, 22 Aug 2022 14:06:53 +0000 (+0000) Subject: database: Improve error reporting when the magic cannot be read X-Git-Tag: 0.9.15~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=808d6ac80fd919897c08a10950bb8f53d24b5ba9;p=location%2Flibloc.git database: Improve error reporting when the magic cannot be read Signed-off-by: Michael Tremer --- diff --git a/src/database.c b/src/database.c index b28166a..d2b76f8 100644 --- a/src/database.c +++ b/src/database.c @@ -142,7 +142,7 @@ static int loc_database_read_magic(struct loc_database* db) { if (bytes_read < sizeof(magic)) { ERROR(db->ctx, "Could not read enough data to validate magic bytes\n"); DEBUG(db->ctx, "Read %zu bytes, but needed %zu\n", bytes_read, sizeof(magic)); - return -ENOMSG; + goto ERROR; } // Compare magic bytes @@ -155,7 +155,9 @@ static int loc_database_read_magic(struct loc_database* db) { return 0; } +ERROR: ERROR(db->ctx, "Unrecognized file type\n"); + errno = ENOMSG; // Return an error return 1;