scst_main: Terminate trace output for an empty CDB

The saved Cppcheck report warns about the formatter output:

  scst/src/scst_main.c:637: warning: Uninitialized variable: buf
  [uninitvar]

scst_dump_cdb does not write anything when cdb_len is zero, but
scst_trace_cmds prints its stack buffer as a string. Unknown opcode
groups can produce an empty CDB, so termination must not depend on
valid command contents.

Initialize nonempty output buffers and leave zero-capacity buffers
untouched. Add KUnit coverage for empty, ordinary, truncated, one-byte
and zero-size output. Include the new private test header in generated
kernel patches.
This commit is contained in:
Gleb Chesnokov
2026-10-21 13:20:12 +03:00
parent e2243f45f1
commit b74e00e63b
4 changed files with 64 additions and 3 deletions
+1
View File
@@ -315,6 +315,7 @@ scst/src/scst_event.c scst/src/scst_event_priv.h scst/src/scst_no_dlm.c \
scst/src/scst_test.h \
scst/src/scst_event_test.h \
scst/src/scst_dlm_test.h \
scst/src/scst_main_test.h \
scst/src/scst_copy_mgr_test.h"
scst_05_targ="scst/src/scst_targ.c scst/src/scst_local_cmd.c \
scst/src/scst_local_cmd.h \