Skip to content

Commit

Permalink
file: Fix some compiler wranings
Browse files Browse the repository at this point in the history
Signed-off-by: Siddharth Chandrasekaran <[email protected]>
  • Loading branch information
sidcha committed Jan 7, 2024
1 parent 66e9e75 commit 7f9d0cb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ int read_binary_file(const char *path, uint8_t **buf, size_t *size)
}
*size = file_size(fp);
*buf = safe_malloc(*size);
fread(*buf, *size, 1, fp);
if (ferror(fp)) {
if (fread(*buf, *size, 1, fp) != 1 || ferror(fp)) {
perror("read failed!");
rc = -1;
}
Expand Down Expand Up @@ -134,14 +133,14 @@ char *path_join(const char *p1, const char *p2)
p2_len = strlen(p2);
path = safe_malloc(sizeof(char) * (p1_len + p2_len + 2));
if (p1) {
strncpy(path, p1, p1_len);
memcpy(path, p1, p1_len);
}
if (p1_len && path[p1_len - 1] != PATH_SEP) {
path[p1_len] = PATH_SEP;
strncpy(path + p1_len + 1, p2, p2_len);
memcpy(path + p1_len + 1, p2, p2_len);
path[p1_len + 1 + p2_len] = '\0';
} else {
strncpy(path + p1_len, p2, p2_len);
memcpy(path + p1_len, p2, p2_len);
path[p1_len + p2_len] = '\0';
}
return path;
Expand Down

0 comments on commit 7f9d0cb

Please sign in to comment.