Package: liboop4 Version: 1.0.1-2.1 Fixes this compiler warning:
read.c: In function 'on_process': read.c:402:38: warning: comparison between pointer and zero character constant [-Wpointer-compare] notnul < buf+thisrecsz && notnul == '\0'; ^~ read.c:402:31: note: did you mean to dereference the pointer? notnul < buf+thisrecsz && notnul == '\0'; History of this fix: See #579604. I am tidying up my own program (innduct), which I find it still has a copy of this file. Comparing the files I find this one difference. I seem to have fixed this bug in 2022 without noticing that I ought to be sending the fix upstream. So, apologies for the delay reporting this. Patch attached. Thanks, Ian.
>From 732e5f352205cc1d67ee28ea68fa02869aba5551 Mon Sep 17 00:00:00 2001 From: Ian Jackson <ijack...@chiark.greenend.org.uk> Date: Sat, 27 Jan 2024 13:03:00 +0000 Subject: [PATCH] read.c: Fix missing dereference - bug with OOP_RD_NUL_DISCARD Fixes this compiler warning: read.c: In function 'on_process': read.c:402:38: warning: comparison between pointer and zero character constant [-Wpointer-compare] notnul < buf+thisrecsz && notnul == '\0'; ^~ read.c:402:31: note: did you mean to dereference the pointer? notnul < buf+thisrecsz && notnul == '\0'; ^ I think the impact would be that OOP_RD_NUL_DISCARD would pass through (fail to discard) all but the first nul in each buffer-full. I wrote this file originally. I don't know why I didn't use memchr instead of this open-coded loop. But, I'm don't think it's a good idea to refactor it now. --- read.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/read.c b/read.c index 38cba00..deaadb5 100644 --- a/read.c +++ b/read.c @@ -399,7 +399,7 @@ static void *on_process(oop_source *oop, oop_read *rd, int try_read) { } assert(rd->style.nul_mode == OOP_RD_NUL_DISCARD); for (notnul= nul+1; - notnul < buf+thisrecsz && notnul == '\0'; + notnul < buf+thisrecsz && *notnul == '\0'; notnul++); thisrecsz-= (notnul-nul); checked= nul-buf; -- 2.20.1
-- Ian Jackson <ijack...@chiark.greenend.org.uk> These opinions are my own. Pronouns: they/he. If I emailed you from @fyvzl.net or @evade.org.uk, that is a private address which bypasses my fierce spamfilter.