Skip to content

Commit f3732b2

Browse files
abonislawskikv2019i
authored andcommitted
tools: rimage: return a negative error code from elf_error()
elf_error() negates its argument, so an already negative code was turned into a positive value that callers testing "ret < 0" take for success. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent b8d5999 commit f3732b2

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

tools/rimage/src/elf_file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ static struct name_val p_flags[] = {
9595
*
9696
* @param elf elf file structure
9797
* @param msg error message
98-
* @param error error code to return
99-
* @return error code
98+
* @param error positive errno value, or an already negative error code
99+
* @return negative error code
100100
*/
101101
static int elf_error(const struct elf_file *elf, const char *msg, int error)
102102
{
103103
fprintf(stderr, "Error: %s: %s\n", elf->filename, msg);
104-
return -error;
104+
return error < 0 ? error : -error;
105105
}
106106

107107
/**

0 commit comments

Comments
 (0)