From c3dce698ab45d2c4c46d27caf123c8548d4545d8 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 23 Jan 2010 01:13:30 +0000 Subject: [PATCH] use size_t with strlen instead of casting randomly to ints git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1698 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 3 +++ urjtag/src/cmd/cmd_pod.c | 2 +- urjtag/src/cmd/cmd_shell.c | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 5b78435c..3f1a1405 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -8,6 +8,9 @@ * src/cmd/cmd_shell.c (cmd_shell_run): Log non-zero shell exit status. + * src/cmd/cmd_pod.c (cmd_pod_run), src/cmd/cmd_shell.c (cmd_shell_run): + Fix size_t handling with strlen. + 2010-01-21 Jie Zhang * src/apps/jtag/jtag.c (main): Don't trigger open file error diff --git a/urjtag/src/cmd/cmd_pod.c b/urjtag/src/cmd/cmd_pod.c index 73ad6e42..ac472265 100644 --- a/urjtag/src/cmd/cmd_pod.c +++ b/urjtag/src/cmd/cmd_pod.c @@ -68,7 +68,7 @@ cmd_pod_run (urj_chain_t *chain, char *params[]) } urj_pod_sigsel_t it = URJ_POD_CS_NONE; - int n = strlen (params[j]); + size_t n = strlen (params[j]); if (n > 4 && (strncasecmp (params[j], "tck", 3) == 0)) it = URJ_POD_CS_TCK; diff --git a/urjtag/src/cmd/cmd_shell.c b/urjtag/src/cmd/cmd_shell.c index d608702b..e32d35d0 100644 --- a/urjtag/src/cmd/cmd_shell.c +++ b/urjtag/src/cmd/cmd_shell.c @@ -39,7 +39,8 @@ static int cmd_shell_run (urj_chain_t *chain, char *params[]) { - int i, len, n = urj_cmd_params (params); + int i, n = urj_cmd_params (params); + size_t len; char *shell_cmd; if ((n = urj_cmd_params (params)) == 1) @@ -65,8 +66,8 @@ cmd_shell_run (urj_chain_t *chain, char *params[]) shell_cmd = malloc (len); if (shell_cmd == NULL) { - urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails", - (size_t) len); + urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zu) fails", + len); return URJ_STATUS_FAIL; }