From 4ad11ee364c1111e2dc567fdd0d1f27aaa85311a Mon Sep 17 00:00:00 2001 From: diamant3 Date: Thu, 19 Jan 2023 13:21:22 +0800 Subject: [PATCH] suppress unused result warning --- tools/PrxEncrypter/main.c | 7 ++++++- tools/pack-pbp.c | 3 ++- tools/psp-fixup-imports.c | 7 ++++++- tools/psp-prxgen.c | 7 ++++++- tools/unpack-pbp.c | 6 ++++-- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/tools/PrxEncrypter/main.c b/tools/PrxEncrypter/main.c index 6ce0af45..6ab58033 100644 --- a/tools/PrxEncrypter/main.c +++ b/tools/PrxEncrypter/main.c @@ -181,7 +181,12 @@ int load_elf(char *elff) fseek(fp, 0, SEEK_END); int size = ftell(fp); fseek(fp, 0, SEEK_SET); - fread(elf, 1, size, fp); + size_t result = fread(elf, 1, size, fp); + if (result < 0) { + fprintf(stderr, "Error, could not read the ELF\n"); + fclose(fp); + return -1; + } fclose(fp); return size; diff --git a/tools/pack-pbp.c b/tools/pack-pbp.c index cdfa358d..6f1cc6ef 100644 --- a/tools/pack-pbp.c +++ b/tools/pack-pbp.c @@ -158,7 +158,8 @@ int main(int argc, char *argv[]) { int loop0, result; } // Read in the data from the file - if (fread(buffer, readsize, 1, infile) < 0) { + size_t result = fread(buffer, readsize, 1, infile); + if (result < 0) { printf("ERROR: Could not read in the file data. (%s)\n", argv[2 + loop0]); return -1; } diff --git a/tools/psp-fixup-imports.c b/tools/psp-fixup-imports.c index 5aec7d39..1f3b082e 100644 --- a/tools/psp-fixup-imports.c +++ b/tools/psp-fixup-imports.c @@ -195,7 +195,12 @@ unsigned char *load_file(const char *file, unsigned int *size) break; } - (void) fread(data, 1, *size, fp); + size_t result = fread(data, 1, *size, fp); + if (result < 0) { + fprintf(stderr, "Error, could not read the ELF\n"); + fclose(fp); + break; + } fclose(fp); } else diff --git a/tools/psp-prxgen.c b/tools/psp-prxgen.c index c68252bc..3cac3925 100644 --- a/tools/psp-prxgen.c +++ b/tools/psp-prxgen.c @@ -144,7 +144,12 @@ unsigned char *load_file(const char *file) break; } - (void) fread(data, 1, size, fp); + size_t result = fread(data, 1, size, fp); + if (result < 0) { + fprintf(stderr, "Error, could not read the ELF\n"); + fclose(fp); + break; + } fclose(fp); } else diff --git a/tools/unpack-pbp.c b/tools/unpack-pbp.c index 57afcf97..2ddd9b57 100644 --- a/tools/unpack-pbp.c +++ b/tools/unpack-pbp.c @@ -96,7 +96,8 @@ int main(int argc, char *argv[]) { } // Read in the header - if (fread(&header, sizeof(HEADER), 1, infile) < 0) { + size_t result = fread(&header, sizeof(HEADER), 1, infile); + if (result < 0) { printf("ERROR: Could not read the input file header.\n"); return -1; } @@ -168,7 +169,8 @@ int main(int argc, char *argv[]) { size -= readsize; // Read in the data from the PBP - if (fread(buffer, readsize, 1, infile) < 0) { + size_t result = fread(buffer, readsize, 1, infile); + if (result < 0) { printf("ERROR: Could not read in the section data.\n"); free(buffer); return -1;