Jim_GetOptInfo goi;
Jim_GetOpt_Setup(&goi, interp, argc - 1, argv + 1);
- if (goi.argc != 2 && goi.argc != 3)
+ /* danger! goi.argc will be modified below! */
+ argc = goi.argc;
+
+ if (argc != 2 && argc != 3)
{
Jim_SetResult_sprintf(goi.interp,
"usage: %s <address> <data> [<count>]", cmd_name);
return JIM_ERR;
}
+
jim_wide a;
int e = Jim_GetOpt_Wide(&goi, &a);
if (e != JIM_OK)
return e;
jim_wide c = 1;
- if (goi.argc == 3)
+ if (argc == 3)
{
e = Jim_GetOpt_Wide(&goi, &c);
if (e != JIM_OK)
Jim_GetOptInfo goi;
Jim_GetOpt_Setup(&goi, interp, argc - 1, argv + 1);
- if ((goi.argc == 2) || (goi.argc == 3))
+ /* danger! goi.argc will be modified below! */
+ argc = goi.argc;
+
+ if ((argc != 1) && (argc != 2))
{
Jim_SetResult_sprintf(goi.interp,
"usage: %s <address> [<count>]", cmd_name);
return JIM_ERR;
}
jim_wide c;
- if (goi.argc) {
+ if (argc == 2) {
e = Jim_GetOpt_Wide(&goi, &c);
if (e != JIM_OK) {
return JIM_ERR;
case 4:
for (x = 0; x < 16 && x < y; x += 4)
{
- z = target_buffer_get_u32(target, &(target_buf[ x * 4 ]));
+ z = target_buffer_get_u32(target, &(target_buf[ x ]));
Jim_fprintf(interp, interp->cookie_stdout, "%08x ", (int)(z));
}
for (; (x < 16) ; x += 4) {
case 2:
for (x = 0; x < 16 && x < y; x += 2)
{
- z = target_buffer_get_u16(target, &(target_buf[ x * 2 ]));
+ z = target_buffer_get_u16(target, &(target_buf[ x ]));
Jim_fprintf(interp, interp->cookie_stdout, "%04x ", (int)(z));
}
for (; (x < 16) ; x += 2) {
case 1:
default:
for (x = 0 ; (x < 16) && (x < y) ; x += 1) {
- z = target_buffer_get_u8(target, &(target_buf[ x * 4 ]));
+ z = target_buffer_get_u8(target, &(target_buf[ x ]));
Jim_fprintf(interp, interp->cookie_stdout, "%02x ", (int)(z));
}
for (; (x < 16) ; x += 1) {