[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] build system: avoid build failure during bisection
From:       Ron Yorston <rmy () pobox ! com>
Date:       2021-04-03 7:57:49
Message-ID: 60681ffd.q21WSbJVjPJ5r+5l%rmy () pobox ! com
[Download RAW message or body]

Commit 4bdc914ff (build system: fix compiler warnings) added a
test on the return value of fgets() in split-include.c.

During bisection it's possible to go back to a state where a
configuration value didn't exist.  This results in an empty
include file corresponding to the missing feature.  If a
subsequent bisection returns to a state where the feature exists
split-include treats the empty file as an error and the build
fails.

Add a call to ferror() to distinguish between fgets() failing
due to an error and due to there being no data to read.

Signed-off-by: Ron Yorston <rmy@pobox.com>
---
 scripts/basic/split-include.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/basic/split-include.c b/scripts/basic/split-include.c
index 791d142a8..a38ac3427 100644
--- a/scripts/basic/split-include.c
+++ b/scripts/basic/split-include.c
@@ -131,7 +131,7 @@ int main(int argc, const char * argv [])
 	is_same = 0;
 	if ((fp_target = fopen(ptarget, "r")) != NULL)
 	{
-	    if (!fgets(old_line, buffer_size, fp_target))
+	    if (!fgets(old_line, buffer_size, fp_target) && ferror(fp_target))
 		ERROR_EXIT(ptarget);
 	    if (fclose(fp_target) != 0)
 		ERROR_EXIT(ptarget);
-- 
2.30.2

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic