X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Fimage.c;h=d72680d1b763499646635c47a4cea7c7791db44e;hb=c6e80f63a3955baed6666e966ab1dd3950ea91b8;hp=2b6d0d11def83ebd35cac5bca16f6ebeaddaf19d;hpb=8c1ec4f0e1a7dd37a2549d83b6cd5c8c57eb34aa;p=openocd.git diff --git a/src/target/image.c b/src/target/image.c index 2b6d0d11de..d72680d1b7 100644 --- a/src/target/image.c +++ b/src/target/image.c @@ -27,20 +27,10 @@ #include "config.h" #endif -#include -#include -#ifdef HAVE_ELF_H -#include -#endif - #include "image.h" - -#include "types.h" -#include "replacements.h" +#include "target.h" #include "log.h" -#include "fileio.h" -#include "target.h" /* convert ELF header field to host endianness */ #define field16(elf,field)\ @@ -217,7 +207,9 @@ static int image_ihex_buffer_complete(image_t *image) while (count-- > 0) { - sscanf(&lpszLine[bytes_read], "%2x", (u32*)&ihex->buffer[cooked_bytes]); + unsigned value; + sscanf(&lpszLine[bytes_read], "%2x", &value); + ihex->buffer[cooked_bytes] = (u8)value; cal_checksum += (u8)ihex->buffer[cooked_bytes]; bytes_read += 2; cooked_bytes += 1; @@ -594,7 +586,9 @@ static int image_mot_buffer_complete(image_t *image) while (count-- > 0) { - sscanf(&lpszLine[bytes_read], "%2x", (u32*)&mot->buffer[cooked_bytes]); + unsigned value; + sscanf(&lpszLine[bytes_read], "%2x", &value); + mot->buffer[cooked_bytes] = (u8)value; cal_checksum += (u8)mot->buffer[cooked_bytes]; bytes_read += 2; cooked_bytes += 1; @@ -717,10 +711,11 @@ int image_open(image_t *image, char *url, char *type_string) } else if (image->type == IMAGE_MEMORY) { - target_t *target = get_target_by_num(strtoul(url, NULL, 0)); - if (target==NULL) + target_t *target = get_target(url); + + if (target == NULL) { - LOG_ERROR("Target '%s' does not exist", url); + LOG_ERROR("target '%s' not defined", url); return ERROR_FAIL; }