[PATCH] mtd: fix compile warnings

Adam adam0320a at gmail.com
Thu Jun 6 19:45:41 PDT 2024


From: Adam-0320 <adam0320a at gmail.com>

ubi-mdeia.h defines 'struct ubi_vid_hdr'. It is used as a parameter type
of function 'ubigen_init_ec_hdr', which is declared in libubigen.h.
ubiformat.c and liubigen.c use this function. And they both have
included ubi-mdeia.h and libubigen.h. However, mtdinfo.c includes
libubigen.h but not ubi-mdeia.h. This also happens to 'ubi_ec_hdr'.
These issues lead to warnings:

In file included from ubi-utils/mtdinfo.c:34:
./include/libubigen.h:124:32: warning: 'struct ubi_ec_hdr' declared
inside parameter list will not be visible outside of this definition
or declaration
  124 |                         struct ubi_ec_hdr *hdr, long long ec);
      |                                ^~~~~~~~~~
./include/libubigen.h:140:33: warning: 'struct ubi_vid_hdr' declared
inside parameter list will not be visible outside of this definition
or declaration
  140 |                          struct ubi_vid_hdr *hdr, int lnum,
      |                                 ^~~~~~~~~~~

So include ubi-media.h in libubigen.h.

Signed-off-by: Adam-0320 <adam0320a at gmail.com>
---
 .../patches/140-mtd-fix-compile-warnings.patch       | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644
package/utils/mtd-utils/patches/140-mtd-fix-compile-warnings.patch

diff --git a/package/utils/mtd-utils/patches/140-mtd-fix-compile-warnings.patch
b/package/utils/mtd-utils/patches/140-mtd-fix-compile-warnings.patch
new file mode 100644
index 0000000..bb07c55
--- /dev/null
+++ b/package/utils/mtd-utils/patches/140-mtd-fix-compile-warnings.patch
@@ -0,0 +1,12 @@
+diff --git a/include/libubigen.h b/include/libubigen.h
+index 48d2fad..0c20979 100644
+--- a/include/libubigen.h
++++ b/include/libubigen.h
+@@ -26,6 +26,7 @@
+ #define __LIBUBIGEN_H__
+
+ #include <stdint.h>
++#include "ubi-media.h"
+
+ #ifdef __cplusplus
+ extern "C" {



More information about the openwrt-devel mailing list