Skip to content
Snippets Groups Projects
Commit 59b92340 authored by Jani Juvan's avatar Jani Juvan
Browse files

Fix static code analysis errors

parent d1eab3e7
Branches master
No related tags found
1 merge request!7Enable CI testing
Pipeline #42832 failed
......@@ -268,7 +268,7 @@ static int get_attribute(char *buf, char *name, char *imagename)
char *read_header(int fd)
{
char *buf;
char *buf, *tmp;
ssize_t len, total_size;
/* Read minimal static struct */
......@@ -289,9 +289,12 @@ char *read_header(int fd)
return NULL;
}
buf = realloc(buf, total_size);
if (!buf)
tmp = realloc(buf, total_size);
if (total_size && !tmp) {
free(buf);
return NULL;
}
buf = tmp;
len = read(fd, buf + FDT_V1_SIZE, total_size - FDT_V1_SIZE);
if (len < total_size - FDT_V1_SIZE) {
......
......@@ -121,7 +121,7 @@ char *join_path(const char *path, const char *name)
bool util_is_printable_string(const void *data, int len)
{
const char *s = data;
const char *ss, *se;
const char *se;
/* zero length is not */
if (len == 0)
......@@ -134,7 +134,7 @@ bool util_is_printable_string(const void *data, int len)
se = s + len;
while (s < se) {
ss = s;
const char *ss = s;
while (s < se && *s && isprint((unsigned char)*s))
s++;
......@@ -385,15 +385,15 @@ int utilfdt_decode_type(const char *fmt, int *type, int *size)
void utilfdt_print_data(const char *data, int len)
{
int i;
const char *s;
/* no data, don't print */
if (len == 0)
return;
if (util_is_printable_string(data, len)) {
printf(" = ");
const char *s;
printf(" = ");
s = data;
do {
printf("\"%s\"", s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment