0040-firmware-utils-mkfwimage-add-Wall-fix-obvious-bugs-causing-compile-warnings.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Thu, 25 Feb 2016 21:39:03 +0100
  3. Subject: firmware-utils: mkfwimage: add -Wall, fix obvious bugs causing compile warnings
  4. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
  5. diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile
  6. index bd69cb4..6d88845 100644
  7. --- a/tools/firmware-utils/Makefile
  8. +++ b/tools/firmware-utils/Makefile
  9. @@ -32,7 +32,7 @@ define Host/Compile
  10. $(call cc,mkzynfw)
  11. $(call cc,lzma2eva,-lz)
  12. $(call cc,mkcasfw)
  13. - $(call cc,mkfwimage,-lz)
  14. + $(call cc,mkfwimage,-lz -Wall)
  15. $(call cc,mkfwimage2,-lz)
  16. $(call cc,imagetag imagetag_cmdline cyg_crc32)
  17. $(call cc,add_header)
  18. diff --git a/tools/firmware-utils/src/mkfwimage.c b/tools/firmware-utils/src/mkfwimage.c
  19. index e3a03c1..00bf439 100644
  20. --- a/tools/firmware-utils/src/mkfwimage.c
  21. +++ b/tools/firmware-utils/src/mkfwimage.c
  22. @@ -104,8 +104,6 @@ typedef struct part_data {
  23. #define OPTIONS "B:hv:m:o:r:k:"
  24. -static int debug = 0;
  25. -
  26. typedef struct image_info {
  27. char magic[16];
  28. char version[256];
  29. @@ -236,9 +234,9 @@ static int create_image_layout(const char* kernelfile, const char* rootfsfile, c
  30. fw_layout_t* p;
  31. p = &fw_layout_data[0];
  32. - while ((strlen(p->name) != 0) && (strncmp(p->name, board_name, sizeof(board_name)) != 0))
  33. + while (*p->name && (strcmp(p->name, board_name) != 0))
  34. p++;
  35. - if (p->name == NULL) {
  36. + if (!*p->name) {
  37. printf("BUG! Unable to find default fw layout!\n");
  38. exit(-1);
  39. }
  40. @@ -247,7 +245,7 @@ static int create_image_layout(const char* kernelfile, const char* rootfsfile, c
  41. strcpy(kernel->partition_name, "kernel");
  42. kernel->partition_index = 1;
  43. kernel->partition_baseaddr = p->kern_start;
  44. - if ( (kernel->partition_length = filelength(kernelfile)) < 0) return (-1);
  45. + if ( (kernel->partition_length = filelength(kernelfile)) == (u_int32_t)-1) return (-1);
  46. kernel->partition_memaddr = p->kern_entry;
  47. kernel->partition_entryaddr = p->kern_entry;
  48. strncpy(kernel->filename, kernelfile, sizeof(kernel->filename));
  49. @@ -263,8 +261,8 @@ static int create_image_layout(const char* kernelfile, const char* rootfsfile, c
  50. rootfs->partition_entryaddr = 0x00000000;
  51. strncpy(rootfs->filename, rootfsfile, sizeof(rootfs->filename));
  52. -printf("kernel: %d 0x%08x\n", kernel->partition_length, kernel->partition_baseaddr);
  53. -printf("root: %d 0x%08x\n", rootfs->partition_length, rootfs->partition_baseaddr);
  54. + printf("kernel: %d 0x%08x\n", kernel->partition_length, kernel->partition_baseaddr);
  55. + printf("root: %d 0x%08x\n", rootfs->partition_length, rootfs->partition_baseaddr);
  56. im->part_count = 2;
  57. return 0;