Skip to content

Commit

Permalink
Try to reduce compiler warnings
Browse files Browse the repository at this point in the history
Please review carefully
  • Loading branch information
probonopd authored Jul 13, 2024
1 parent e2157b0 commit 8a0d86f
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/runtime/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ static off_t read_elf32(FILE* fd) {
fseeko(fd, 0, SEEK_SET);
ret = fread(&ehdr32, 1, sizeof(ehdr32), fd);
if (ret < 0 || (size_t) ret != sizeof(ehdr32)) {
fprintf(stderr, "Read of ELF header from %s failed: %s\n",
fname, strerror(errno));
fprintf(stderr, "Read of ELF header from %s failed: %s\n", fname, strerror(errno));
return -1;
}

Expand All @@ -231,8 +230,7 @@ static off_t read_elf32(FILE* fd) {
fseeko(fd, last_shdr_offset, SEEK_SET);
ret = fread(&shdr32, 1, sizeof(shdr32), fd);
if (ret < 0 || (size_t) ret != sizeof(shdr32)) {
fprintf(stderr, "Read of ELF section header from %s failed: %s\n",
fname, strerror(errno));
fprintf(stderr, "Read of ELF section header from %s failed: %s\n", fname, strerror(errno));
return -1;
}

Expand All @@ -252,8 +250,7 @@ static off_t read_elf64(FILE* fd) {
fseeko(fd, 0, SEEK_SET);
ret = fread(&ehdr64, 1, sizeof(ehdr64), fd);
if (ret < 0 || (size_t) ret != sizeof(ehdr64)) {
fprintf(stderr, "Read of ELF header from %s failed: %s\n",
fname, strerror(errno));
fprintf(stderr, "Read of ELF header from %s failed: %s\n", fname, strerror(errno));
return -1;
}

Expand All @@ -265,8 +262,7 @@ static off_t read_elf64(FILE* fd) {
fseeko(fd, last_shdr_offset, SEEK_SET);
ret = fread(&shdr64, 1, sizeof(shdr64), fd);
if (ret < 0 || ret != sizeof(shdr64)) {
fprintf(stderr, "Read of ELF section header from %s failed: %s\n",
fname, strerror(errno));
fprintf(stderr, "Read of ELF section header from %s failed: %s\n", fname, strerror(errno));
return -1;
}

Expand All @@ -289,8 +285,7 @@ ssize_t appimage_get_elf_size(const char* fname) {
}
ret = fread(ehdr.e_ident, 1, EI_NIDENT, fd);
if (ret != EI_NIDENT) {
fprintf(stderr, "Read of e_ident from %s failed: %s\n",
fname, strerror(errno));
fprintf(stderr, "Read of e_ident from %s failed: %s\n", fname, strerror(errno));
return -1;
}
if ((ehdr.e_ident[EI_DATA] != ELFDATA2LSB) &&
Expand Down Expand Up @@ -904,8 +899,8 @@ int fusefs_main(int argc, char* argv[], void (* mounted)(void)) {
struct fuse_opt fuse_opts[] = {
{"offset=%zu", offsetof(sqfs_opts, offset), 0},
{"timeout=%u", offsetof(sqfs_opts, idle_timeout_secs), 0},
{"fsname=%s", "squashfuse", 0},
{"subtype=%s", "squashfuse", 0},
{"fsname=%s", (const char *)"squashfuse", 0},
{"subtype=%s", (const char *)"squashfuse", 0},
FUSE_OPT_END
};

Expand All @@ -923,7 +918,7 @@ int fusefs_main(int argc, char* argv[], void (* mounted)(void)) {
sqfs_ll_ops.readlink = sqfs_ll_op_readlink;
sqfs_ll_ops.listxattr = sqfs_ll_op_listxattr;
sqfs_ll_ops.getxattr = sqfs_ll_op_getxattr;
sqfs_ll_ops.forget = sqfs_ll_op_forget;
sqfs_ll_ops.forget = (void (*)(struct fuse_req *, fuse_ino_t, uint64_t))sqfs_ll_op_forget;
sqfs_ll_ops.statfs = stfs_ll_op_statfs;

/* PARSE ARGS */
Expand Down Expand Up @@ -1422,7 +1417,6 @@ int main(int argc, char* argv[]) {
}

// calculate full path of AppImage
int length;
char fullpath[PATH_MAX];

if (getenv("TARGET_APPIMAGE") == NULL) {
Expand Down Expand Up @@ -1459,14 +1453,14 @@ int main(int argc, char* argv[]) {
Md5Initialise(&ctx);

char buf[4096];
for (size_t bytes_read; (bytes_read = fread(buf, sizeof(char), sizeof(buf), f)); bytes_read > 0) {
for (size_t bytes_read; (bytes_read = fread(buf, sizeof(char), sizeof(buf), f)) > 0; ) {
Md5Update(&ctx, buf, (uint32_t) bytes_read);
}

MD5_HASH digest;
Md5Finalise(&ctx, &digest);

hexlified_digest = appimage_hexlify(digest.bytes, sizeof(digest.bytes));
hexlified_digest = appimage_hexlify((const char*)digest.bytes, sizeof(digest.bytes));
}

char* prefix = malloc(strlen(temp_base) + 20 + strlen(hexlified_digest) + 2);
Expand Down

0 comments on commit 8a0d86f

Please sign in to comment.