error handling: the error number is not part of the user interface

Do not propagate error number to user. This is for internal
programming purposes only. Error messages to the user is
reported as text via LOG_ERROR().

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
__archive__
Øyvind Harboe 2011-01-03 13:30:28 +01:00
parent 1795239cfd
commit c69553cbc5
12 changed files with 26 additions and 29 deletions

View File

@ -46,7 +46,7 @@ int flash_driver_erase(struct flash_bank *bank, int first, int last)
retval = bank->driver->erase(bank, first, last); retval = bank->driver->erase(bank, first, last);
if (retval != ERROR_OK) if (retval != ERROR_OK)
{ {
LOG_ERROR("failed erasing sectors %d to %d (%d)", first, last, retval); LOG_ERROR("failed erasing sectors %d to %d", first, last);
} }
return retval; return retval;
@ -80,7 +80,7 @@ int flash_driver_protect(struct flash_bank *bank, int set, int first, int last)
retval = bank->driver->protect(bank, set, first, last); retval = bank->driver->protect(bank, set, first, last);
if (retval != ERROR_OK) if (retval != ERROR_OK)
{ {
LOG_ERROR("failed setting protection for areas %d to %d (%d)", first, last, retval); LOG_ERROR("failed setting protection for areas %d to %d", first, last);
} }
return retval; return retval;
@ -94,8 +94,8 @@ int flash_driver_write(struct flash_bank *bank,
retval = bank->driver->write(bank, buffer, offset, count); retval = bank->driver->write(bank, buffer, offset, count);
if (retval != ERROR_OK) if (retval != ERROR_OK)
{ {
LOG_ERROR("error writing to flash at address 0x%08" PRIx32 " at offset 0x%8.8" PRIx32 " (%d)", LOG_ERROR("error writing to flash at address 0x%08" PRIx32 " at offset 0x%8.8" PRIx32,
bank->base, offset, retval); bank->base, offset);
} }
return retval; return retval;
@ -111,8 +111,8 @@ int flash_driver_read(struct flash_bank *bank,
retval = bank->driver->read(bank, buffer, offset, count); retval = bank->driver->read(bank, buffer, offset, count);
if (retval != ERROR_OK) if (retval != ERROR_OK)
{ {
LOG_ERROR("error reading to flash at address 0x%08" PRIx32 " at offset 0x%8.8" PRIx32 " (%d)", LOG_ERROR("error reading to flash at address 0x%08" PRIx32 " at offset 0x%8.8" PRIx32,
bank->base, offset, retval); bank->base, offset);
} }
return retval; return retval;
@ -209,7 +209,7 @@ int get_flash_bank_by_name(const char *name, struct flash_bank **bank_result)
if (retval != ERROR_OK) if (retval != ERROR_OK)
{ {
LOG_ERROR("auto_probe failed %d\n", retval); LOG_ERROR("auto_probe failed\n");
return retval; return retval;
} }
} }
@ -232,7 +232,7 @@ int get_flash_bank_by_num(int num, struct flash_bank **bank)
if (retval != ERROR_OK) if (retval != ERROR_OK)
{ {
LOG_ERROR("auto_probe failed %d\n", retval); LOG_ERROR("auto_probe failed\n");
return retval; return retval;
} }
*bank = p; *bank = p;
@ -253,7 +253,7 @@ int get_flash_bank_by_addr(struct target *target, uint32_t addr, bool check, str
if (retval != ERROR_OK) if (retval != ERROR_OK)
{ {
LOG_ERROR("auto_probe failed %d\n", retval); LOG_ERROR("auto_probe failed\n");
return retval; return retval;
} }
/* check whether address belongs to this flash bank */ /* check whether address belongs to this flash bank */

View File

@ -513,8 +513,8 @@ static int pic32mx_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offs
} }
else if (retval == ERROR_FLASH_OPERATION_FAILED) else if (retval == ERROR_FLASH_OPERATION_FAILED)
{ {
LOG_ERROR("flash writing failed with error code: 0x%x", retval); LOG_ERROR("flash writing failed");
return ERROR_FLASH_OPERATION_FAILED; return retval;
} }
} }
else else

View File

@ -325,10 +325,6 @@ static int str7x_result(struct flash_bank *bank)
err = ERROR_FAIL; err = ERROR_FAIL;
} }
} }
if (err != ERROR_OK)
{
LOG_ERROR("FLASH_ER register contents: 0x%" PRIx32, retval);
}
return retval; return retval;
} }

View File

@ -562,7 +562,7 @@ static int str9x_write(struct flash_bank *bank,
} }
else if (retval == ERROR_FLASH_OPERATION_FAILED) else if (retval == ERROR_FLASH_OPERATION_FAILED)
{ {
LOG_ERROR("flash writing failed with error code: 0x%x", retval); LOG_ERROR("flash writing failed");
return ERROR_FLASH_OPERATION_FAILED; return ERROR_FLASH_OPERATION_FAILED;
} }
} }

View File

@ -106,7 +106,7 @@ COMMAND_HANDLER(handle_flash_info_command)
retval = p->driver->info(p, buf, sizeof(buf)); retval = p->driver->info(p, buf, sizeof(buf));
command_print(CMD_CTX, "%s", buf); command_print(CMD_CTX, "%s", buf);
if (retval != ERROR_OK) if (retval != ERROR_OK)
LOG_ERROR("error retrieving flash info (%d)", retval); LOG_ERROR("error retrieving flash info");
} }
return ERROR_OK; return ERROR_OK;

View File

@ -133,7 +133,7 @@ COMMAND_HANDLER(handle_cat_command)
} }
else else
{ {
command_print(CMD_CTX, "%s not found %d", CMD_ARGV[0], retval); command_print(CMD_CTX, "%s not found", CMD_ARGV[0]);
} }
return ERROR_OK; return ERROR_OK;
@ -270,7 +270,7 @@ COMMAND_HANDLER(handle_cp_command)
command_print(CMD_CTX, "Copied %s to %s", CMD_ARGV[0], CMD_ARGV[1]); command_print(CMD_CTX, "Copied %s to %s", CMD_ARGV[0], CMD_ARGV[1]);
} else } else
{ {
command_print(CMD_CTX, "Failed: %d", retval); command_print(CMD_CTX, "copy failed");
} }
if (data != NULL) if (data != NULL)

View File

@ -695,7 +695,7 @@ void jtag_add_reset(int req_tlr_or_trst, int req_srst)
retval = jtag_execute_queue(); retval = jtag_execute_queue();
if (retval != ERROR_OK) { if (retval != ERROR_OK) {
LOG_ERROR("TRST/SRST error %d", retval); LOG_ERROR("TRST/SRST error");
return; return;
} }
} }

View File

@ -82,8 +82,8 @@ static int transport_select(struct command_context *ctx, const char *name)
if (retval == ERROR_OK) if (retval == ERROR_OK)
session = t; session = t;
else else
LOG_ERROR("Error %d selecting '%s' as " LOG_ERROR("Error selecting '%s' as "
"transport", retval, t->name); "transport", t->name);
return retval; return retval;
} }
} }

View File

@ -175,7 +175,7 @@ static int arm11_debug_entry(struct arm11_common *arm11)
*/ */
retval = arm_dpm_read_current_registers(&arm11->dpm); retval = arm_dpm_read_current_registers(&arm11->dpm);
if (retval != ERROR_OK) if (retval != ERROR_OK)
LOG_ERROR("DPM REG READ -- fail %d", retval); LOG_ERROR("DPM REG READ -- fail");
retval = arm11_run_instr_data_prepare(arm11); retval = arm11_run_instr_data_prepare(arm11);
if (retval != ERROR_OK) if (retval != ERROR_OK)

View File

@ -1533,7 +1533,7 @@ static int cortex_m3_store_core_reg_u32(struct target *target,
{ {
struct reg *r; struct reg *r;
LOG_ERROR("JTAG failure %i", retval); LOG_ERROR("JTAG failure");
r = armv7m->core_cache->reg_list + num; r = armv7m->core_cache->reg_list + num;
r->dirty = r->valid; r->dirty = r->valid;
return ERROR_JTAG_DEVICE_ERROR; return ERROR_JTAG_DEVICE_ERROR;

View File

@ -669,7 +669,7 @@ static int etm_read_instruction(struct etm_context *ctx, struct arm_instruction
ctx->current_pc - ctx->image->sections[section].base_address, ctx->current_pc - ctx->image->sections[section].base_address,
4, buf, &size_read)) != ERROR_OK) 4, buf, &size_read)) != ERROR_OK)
{ {
LOG_ERROR("error while reading instruction: %i", retval); LOG_ERROR("error while reading instruction");
return ERROR_TRACE_INSTRUCTION_UNAVAILABLE; return ERROR_TRACE_INSTRUCTION_UNAVAILABLE;
} }
opcode = target_buffer_get_u32(ctx->target, buf); opcode = target_buffer_get_u32(ctx->target, buf);
@ -682,7 +682,7 @@ static int etm_read_instruction(struct etm_context *ctx, struct arm_instruction
ctx->current_pc - ctx->image->sections[section].base_address, ctx->current_pc - ctx->image->sections[section].base_address,
2, buf, &size_read)) != ERROR_OK) 2, buf, &size_read)) != ERROR_OK)
{ {
LOG_ERROR("error while reading instruction: %i", retval); LOG_ERROR("error while reading instruction");
return ERROR_TRACE_INSTRUCTION_UNAVAILABLE; return ERROR_TRACE_INSTRUCTION_UNAVAILABLE;
} }
opcode = target_buffer_get_u16(ctx->target, buf); opcode = target_buffer_get_u16(ctx->target, buf);
@ -2109,6 +2109,7 @@ COMMAND_HANDLER(handle_etm_analyze_command)
if ((retval = etmv1_analyze_trace(etm_ctx, CMD_CTX)) != ERROR_OK) if ((retval = etmv1_analyze_trace(etm_ctx, CMD_CTX)) != ERROR_OK)
{ {
/* FIX! error should be reported inside etmv1_analyze_trace() */
switch (retval) switch (retval)
{ {
case ERROR_ETM_ANALYSIS_FAILED: case ERROR_ETM_ANALYSIS_FAILED:
@ -2121,7 +2122,7 @@ COMMAND_HANDLER(handle_etm_analyze_command)
command_print(CMD_CTX, "no image available for trace analysis"); command_print(CMD_CTX, "no image available for trace analysis");
break; break;
default: default:
command_print(CMD_CTX, "unknown error: %i", retval); command_print(CMD_CTX, "unknown error");
} }
} }

View File

@ -2753,7 +2753,7 @@ static int xscale_read_instruction(struct target *target, uint32_t pc,
pc - xscale->trace.image->sections[section].base_address, pc - xscale->trace.image->sections[section].base_address,
4, buf, &size_read)) != ERROR_OK) 4, buf, &size_read)) != ERROR_OK)
{ {
LOG_ERROR("error while reading instruction: %i", retval); LOG_ERROR("error while reading instruction");
return ERROR_TRACE_INSTRUCTION_UNAVAILABLE; return ERROR_TRACE_INSTRUCTION_UNAVAILABLE;
} }
opcode = target_buffer_get_u32(target, buf); opcode = target_buffer_get_u32(target, buf);
@ -2766,7 +2766,7 @@ static int xscale_read_instruction(struct target *target, uint32_t pc,
pc - xscale->trace.image->sections[section].base_address, pc - xscale->trace.image->sections[section].base_address,
2, buf, &size_read)) != ERROR_OK) 2, buf, &size_read)) != ERROR_OK)
{ {
LOG_ERROR("error while reading instruction: %i", retval); LOG_ERROR("error while reading instruction");
return ERROR_TRACE_INSTRUCTION_UNAVAILABLE; return ERROR_TRACE_INSTRUCTION_UNAVAILABLE;
} }
opcode = target_buffer_get_u16(target, buf); opcode = target_buffer_get_u16(target, buf);