When building with a fortify-enabled toolchain, one would get:
scripts/signGP.c:305:8: warning: ignoring return value of .fread., declared with attribute warn_unused_result
Signed-off-by: LoïMinier <loic.minier@linaro.org>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
- fwrite(&config_header, 1, 512, ofile);
+ if (fwrite(&config_header, 1, 512, ofile) <= 0)
+ pdie("fwrite");
- fwrite(&len, 1, 4, ofile);
- fwrite(&loadaddr, 1, 4, ofile);
+ if (fwrite(&len, 1, 4, ofile) <= 0)
+ pdie("fwrite");
+ if (fwrite(&loadaddr, 1, 4, ofile) <= 0)
+ pdie("fwrite");
for (i = 0; i < len; i++) {
for (i = 0; i < len; i++) {
- fread(&ch, 1, 1, ifile);
- fwrite(&ch, 1, 1, ofile);
+ if (fread(&ch, 1, 1, ifile) <= 0)
+ pdie("fread");
+ if (fwrite(&ch, 1, 1, ofile) <= 0)
+ pdie("fwrite");
- fclose(ifile);
- fclose(ofile);
+ if (!fclose(ifile))
+ perror("warning: fclose");
+ if (!fclose(ofile))
+ perror("warning: fclose");