tools/bootconfig: Fix apply_xbc() to return zero on success
PATCH 1/1 tools/bootconfig: Fix apply_xbc() to return zero on success
From: "Steven Rostedt (VMware)" <[email protected]>
The return of apply_xbc() returns the result of the last write() call, which is not what is expected. It should only return zero on success.
--- tools/bootconfig/main.c | 1 + 1 file changed, 1 insertion(+)
tools/bootconfig/main.c +1 -0
@@ -337,6 +337,7 @@ int apply_xbc(const char *path, const char *xbc_path)pr_err ("Failed to apply a boot config magic: %d\n" , ret); goto out; } + ret =0 ; out:close (fd);free (data);
Signature · 1 line
2.20.1
Quoted 7 lines · On Fri, 8 May 2020 11:13:49 -0400 Steven Rostedt <[email protected]> wrote:
From: "Steven Rostedt (VMware)" <[email protected]>
The return of
apply_xbc()returns the result of the lastwrite()call, which is not what is expected. It should only return zero on success.
Thanks for fixing!
Quoted 22 lines
Fixes 8842604446d1 ("tools/bootconfig: Fix resource leak in apply_xbc()")Reported-by Dan Carpenter <[email protected]>Signed-off-by Steven Rostedt (VMware) <[email protected]>--- tools/bootconfig/main.c | 1 + 1 file changed, 1 insertion(+)tools/bootconfig/main.c +1
-0@@ -337,6 +337,7 @@ int apply_xbc(const char *path, const char *xbc_path)pr_err ("Failed to apply a boot config magic: %d\n" , ret); goto out; } + ret =0 ; out:close (fd);free (data);Signature · 1 line
2.20.1
Signature · 1 line
Masami Hiramatsu <[email protected]>
Quoted 8 lines · On Sat, 9 May 2020 08:14:24 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 5 lines · On Fri, 8 May 2020 11:13:49 -0400 Steven Rostedt <[email protected]> wrote:
From: "Steven Rostedt (VMware)" <[email protected]>
The return of
apply_xbc()returns the result of the lastwrite()call, which is not what is expected. It should only return zero on success.
Quoted 7 lines
Quoted 2 lines
Thanks for fixing!
Acked-by Masami Hiramatsu <[email protected]>
Oh, and tested too.
---
...
test case 40 (samples/good-tree.bconf)...
Apply samples/good-tree.bconf to ./initrd-tNhd
Number of nodes: 16 Size: 136 bytes Checksum: 9171 [OK]
All tests passed
---
BTW, I might better add a test summary to the test script (and move it into kselftest?)
Thank you,
Quoted 27 lines
Quoted 23 lines
Fixes 8842604446d1 ("tools/bootconfig: Fix resource leak in apply_xbc()")Reported-by Dan Carpenter <[email protected]>Signed-off-by Steven Rostedt (VMware) <[email protected]>--- tools/bootconfig/main.c | 1 + 1 file changed, 1 insertion(+)tools/bootconfig/main.c +1
-0@@ -337,6 +337,7 @@ int apply_xbc(const char *path, const char *xbc_path)pr_err ("Failed to apply a boot config magic: %d\n" , ret); goto out; } + ret =0 ; out:close (fd);free (data);Signature · 1 line
2.20.1Signature · 1 line
Masami Hiramatsu <[email protected]>
Signature · 1 line
Masami Hiramatsu <[email protected]>
Masami Hiramatsu
maintainerPATCH 1/1 tools/bootconfig: Add a summary of test cases and return error
Add summary lines of test cases and return an error code if any test case fails so that tester don't have to monitor the output.
--- tools/bootconfig/test-bootconfig.sh | 7 +++++++ 1 file changed, 7 insertions(+)
tools/bootconfig/test-bootconfig.sh +7 -0
@@ -124,9 +124,16 @@ for i in samples/good-* ; do xpass $BOOTCONF -a $i $INITRD done + +echo +echo "=== Summary ===" +echo "# of Passed: $(expr $NO - $NG - 1)" +echo "# of Failed: $NG" + echo if [ $NG -eq 0 ]; then echo "All tests passed" else echo "$NG tests failed" + exit 1 fi