aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2023-04-09 00:16:28 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2023-05-05 22:09:09 +0000
commitcd44c6cf83841076b40e7a873285117b7440dd42 (patch)
treed35316357cc3233136a2b60685269efe24d21ca6
parent9dc1d90f64168863d350694d38e5ff7f20a57a7e (diff)
downloadriscv-openocd-cd44c6cf83841076b40e7a873285117b7440dd42.zip
riscv-openocd-cd44c6cf83841076b40e7a873285117b7440dd42.tar.gz
riscv-openocd-cd44c6cf83841076b40e7a873285117b7440dd42.tar.bz2
helper: with pointers, use NULL instead of 0
Don't compare pointers with 0, use NULL when needed. Don't assign pointer to 0, use NULL. Don't pass 0 ad pointer argument, pass NULL. Detected through 'sparse' tool. Change-Id: I3f867cb9c0903f6e396311e7b3970ee5fb3a4231 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7597 Tested-by: jenkins
-rw-r--r--src/helper/command.c2
-rw-r--r--src/helper/jep106.c2
-rw-r--r--src/helper/options.c12
3 files changed, 8 insertions, 8 deletions
diff --git a/src/helper/command.c b/src/helper/command.c
index 235bec8..945b890 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -582,7 +582,7 @@ int command_run_line(struct command_context *context, char *line)
Jim_DeleteAssocData(interp, "retval");
retcode = Jim_SetAssocData(interp, "retval", NULL, &retval);
if (retcode == JIM_OK) {
- retcode = Jim_Eval_Named(interp, line, 0, 0);
+ retcode = Jim_Eval_Named(interp, line, NULL, 0);
Jim_DeleteAssocData(interp, "retval");
}
diff --git a/src/helper/jep106.c b/src/helper/jep106.c
index d422561..62d24a9 100644
--- a/src/helper/jep106.c
+++ b/src/helper/jep106.c
@@ -26,7 +26,7 @@ const char *jep106_table_manufacturer(unsigned int bank, unsigned int id)
/* index is zero based */
id--;
- if (bank >= ARRAY_SIZE(jep106) || jep106[bank][id] == 0)
+ if (bank >= ARRAY_SIZE(jep106) || !jep106[bank][id])
return "<unknown>";
return jep106[bank][id];
diff --git a/src/helper/options.c b/src/helper/options.c
index 327c418..05cde67 100644
--- a/src/helper/options.c
+++ b/src/helper/options.c
@@ -39,12 +39,12 @@ static int help_flag, version_flag;
static const struct option long_options[] = {
{"help", no_argument, &help_flag, 1},
{"version", no_argument, &version_flag, 1},
- {"debug", optional_argument, 0, 'd'},
- {"file", required_argument, 0, 'f'},
- {"search", required_argument, 0, 's'},
- {"log_output", required_argument, 0, 'l'},
- {"command", required_argument, 0, 'c'},
- {0, 0, 0, 0}
+ {"debug", optional_argument, NULL, 'd'},
+ {"file", required_argument, NULL, 'f'},
+ {"search", required_argument, NULL, 's'},
+ {"log_output", required_argument, NULL, 'l'},
+ {"command", required_argument, NULL, 'c'},
+ {NULL, 0, NULL, 0}
};
int configuration_output_handler(struct command_context *context, const char *line)