From 09cc95b9891255665c62bd1eb3b63b8ddb607615 Mon Sep 17 00:00:00 2001 From: Alexandre Perrin Date: Thu, 14 Jul 2016 16:04:26 +0200 Subject: [PATCH] check_if_png: clarify comments. Before this patch check_if_png() comment was kind of misleading because it talked about the behaviour of png_sig_cmp() which isn't the same as check_if_png(). --- tests/dbgutil.c | 10 +++++++--- tests/dbgutil.h | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/dbgutil.c b/tests/dbgutil.c index 282ee2f..2b040ff 100644 --- a/tests/dbgutil.c +++ b/tests/dbgutil.c @@ -146,8 +146,8 @@ fail: /* hacked from https://dev.w3.org/Amaya/libpng/example.c * - * Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp() - * returns zero if the image is a PNG and nonzero if it isn't a PNG. + * Check if a file is a PNG image using png_sig_cmp(). Returns 1 if the given + * file is a PNG and 0 otherwise. */ #define PNG_BYTES_TO_CHECK 4 int check_if_png(const char *filename) @@ -164,7 +164,11 @@ int check_if_png(const char *filename) if (fread(buf, 1, PNG_BYTES_TO_CHECK, infile) != PNG_BYTES_TO_CHECK) goto out; - /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. */ + /* + * Compare the first PNG_BYTES_TO_CHECK bytes of the signature. + * png_sig_cmp() returns zero if the image is a PNG and nonzero if it + * isn't a PNG. + */ if (png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK) == 0) ret = 1; diff --git a/tests/dbgutil.h b/tests/dbgutil.h index db73dff..7a5cc6a 100644 --- a/tests/dbgutil.h +++ b/tests/dbgutil.h @@ -32,7 +32,10 @@ void dump_cells(const struct quirc_code *code); */ int load_jpeg(struct quirc *q, const char *filename); -/* check if a file is a PNG image. */ +/* Check if a file is a PNG image. + * + * returns 1 if the given file is a PNG and 0 otherwise. + */ int check_if_png(const char *filename); /* Read a PNG image into the decoder.