001-Fix-compilation-warning-with-64-bit-system.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. From ed4422e98ababf956674da3438ac42b3aa32c66e Mon Sep 17 00:00:00 2001
  2. From: Christian Marangi <[email protected]>
  3. Date: Wed, 10 May 2023 00:41:06 +0200
  4. Subject: [PATCH] Fix compilation warning with 64 bit system
  5. Use %zu and %zd where possible for ssize_t and size_t.
  6. Use PTR_ERR to correctly convert to negative error.
  7. Use universal pointer to support both 32 and 64bit systems.
  8. Fix compilation warning:
  9. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/fwcmd.c: In function 'mwl_fwcmd_get_fw_core_dump':
  10. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/fwcmd.c:3608:31: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  11. 3608 | (const void *)((u32)pcmd +
  12. | ^
  13. In file included from ./include/linux/device.h:15,
  14. from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/device.h:3,
  15. from ./include/linux/dma-mapping.h:7,
  16. from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/dma-mapping.h:3,
  17. from ./include/linux/skbuff.h:31,
  18. from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/skbuff.h:3,
  19. from ./include/linux/if_ether.h:19,
  20. from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/if_ether.h:3,
  21. from ./include/linux/etherdevice.h:20,
  22. from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/etherdevice.h:3,
  23. from /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:20:
  24. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c: In function 'pcie_tx_init_ndp':
  25. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:38: error: format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Werror=format=]
  26. 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
  27. | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. ./include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
  29. 110 | _p_func(dev, fmt, ##__VA_ARGS__); \
  30. | ^~~
  31. ./include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
  32. 144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
  33. | ^~~~~~~
  34. /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211/net/cfg80211.h:8828:9: note: in expansion of macro 'dev_err'
  35. 8828 | dev_err(&(wiphy)->dev, format, ##args)
  36. | ^~~~~~~
  37. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:17: note: in expansion of macro 'wiphy_err'
  38. 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
  39. | ^~~~~~~~~
  40. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:67: note: format string is defined here
  41. 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
  42. | ~^
  43. | |
  44. | int
  45. | %ld
  46. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:38: error: format '%d' expects argument of type 'int', but argument 4 has type 'long unsigned int' [-Werror=format=]
  47. 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
  48. | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49. ./include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
  50. 110 | _p_func(dev, fmt, ##__VA_ARGS__); \
  51. | ^~~
  52. ./include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
  53. 144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
  54. | ^~~~~~~
  55. /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211/net/cfg80211.h:8828:9: note: in expansion of macro 'dev_err'
  56. 8828 | dev_err(&(wiphy)->dev, format, ##args)
  57. | ^~~~~~~
  58. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:17: note: in expansion of macro 'wiphy_err'
  59. 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
  60. | ^~~~~~~~~
  61. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:71: note: format string is defined here
  62. 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
  63. | ~^
  64. | |
  65. | int
  66. | %ld
  67. CC [M] /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/debugfs.o
  68. In file included from ./include/linux/device.h:15,
  69. from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/device.h:3,
  70. from ./include/linux/dma-mapping.h:7,
  71. from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/dma-mapping.h:3,
  72. from ./include/linux/skbuff.h:31,
  73. from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/skbuff.h:3,
  74. from ./include/linux/if_ether.h:19,
  75. from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/if_ether.h:3,
  76. from ./include/linux/etherdevice.h:20,
  77. from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/etherdevice.h:3,
  78. from /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.c:19:
  79. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.c: In function 'pcie_bf_mimo_ctrl_decode':
  80. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.c:1325:37: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  81. 1325 | filename, (unsigned int)fp_data);
  82. | ^
  83. ./include/linux/dev_printk.h:110:37: note: in definition of macro 'dev_printk_index_wrap'
  84. 110 | _p_func(dev, fmt, ##__VA_ARGS__); \
  85. | ^~~~~~~~~~~
  86. /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211/net/cfg80211.h:8828:9: note: in expansion of macro 'dev_err'
  87. 8828 | dev_err(&(wiphy)->dev, format, ##args)
  88. | ^~~~~~~
  89. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.c:1324:17: note: in expansion of macro 'wiphy_err'
  90. 1324 | wiphy_err(priv->hw->wiphy, "Error opening %s! %x\n",
  91. | ^~~~~~~~~
  92. cc1: all warnings being treated as errors
  93. make[4]: *** [scripts/Makefile.build:289: /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.o] Error 1
  94. make[4]: *** Waiting for unfinished jobs....
  95. cc1: all warnings being treated as errors
  96. make[4]: *** [scripts/Makefile.build:289: /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.o] Error 1
  97. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/debugfs.c: In function 'mwl_debugfs_regrdwr_read':
  98. /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/debugfs.c:1335:43: error: format '%d' expects argument of type 'int', but argument 4 has type 'ssize_t' {aka 'long int'} [-Werror=format=]
  99. 1335 | "error: %d(%u 0x%08x 0x%08x)\n",
  100. | ~^
  101. | |
  102. | int
  103. | %ld
  104. 1336 | ret, priv->reg_type, priv->reg_offset,
  105. | ~~~
  106. | |
  107. | ssize_t {aka long int}
  108. cc1: all warnings being treated as errors
  109. Signed-off-by: Christian Marangi <[email protected]>
  110. ---
  111. debugfs.c | 2 +-
  112. hif/fwcmd.c | 2 +-
  113. hif/pcie/pcie.c | 4 ++--
  114. hif/pcie/tx_ndp.c | 2 +-
  115. 4 files changed, 5 insertions(+), 5 deletions(-)
  116. diff --git a/debugfs.c b/debugfs.c
  117. index 39b09fd..42efd28 100644
  118. --- a/debugfs.c
  119. +++ b/debugfs.c
  120. @@ -1332,7 +1332,7 @@ done:
  121. priv->reg_value);
  122. else
  123. len += scnprintf(p + len, size - len,
  124. - "error: %d(%u 0x%08x 0x%08x)\n",
  125. + "error: %zd(%u 0x%08x 0x%08x)\n",
  126. ret, priv->reg_type, priv->reg_offset,
  127. priv->reg_value);
  128. diff --git a/hif/fwcmd.c b/hif/fwcmd.c
  129. index 376b58f..582c8d2 100644
  130. --- a/hif/fwcmd.c
  131. +++ b/hif/fwcmd.c
  132. @@ -3604,7 +3604,7 @@ int mwl_fwcmd_get_fw_core_dump(struct ieee80211_hw *hw,
  133. core_dump->size_kb = pcmd->cmd_data.coredump.size_kb;
  134. core_dump->flags = pcmd->cmd_data.coredump.flags;
  135. memcpy(buff,
  136. - (const void *)((u32)pcmd +
  137. + (const void *)((uintptr_t)pcmd +
  138. sizeof(struct hostcmd_cmd_get_fw_core_dump) -
  139. sizeof(struct hostcmd_cmd_get_fw_core_dump_)),
  140. MAX_CORE_DUMP_BUFFER);
  141. diff --git a/hif/pcie/pcie.c b/hif/pcie/pcie.c
  142. index 24453b6..5b6c633 100644
  143. --- a/hif/pcie/pcie.c
  144. +++ b/hif/pcie/pcie.c
  145. @@ -1320,8 +1320,8 @@ static void pcie_bf_mimo_ctrl_decode(struct mwl_priv *priv,
  146. &fp_data->f_pos);
  147. filp_close(fp_data, current->files);
  148. } else {
  149. - wiphy_err(priv->hw->wiphy, "Error opening %s! %x\n",
  150. - filename, (unsigned int)fp_data);
  151. + wiphy_err(priv->hw->wiphy, "Error opening %s! %ld\n",
  152. + filename, PTR_ERR(fp_data));
  153. }
  154. #if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0)
  155. diff --git a/hif/pcie/tx_ndp.c b/hif/pcie/tx_ndp.c
  156. index 6758cde..3140a2e 100644
  157. --- a/hif/pcie/tx_ndp.c
  158. +++ b/hif/pcie/tx_ndp.c
  159. @@ -335,7 +335,7 @@ int pcie_tx_init_ndp(struct ieee80211_hw *hw)
  160. if (sizeof(struct pcie_tx_ctrl_ndp) >
  161. sizeof(tx_info->status.status_driver_data)) {
  162. - wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n",
  163. + wiphy_err(hw->wiphy, "driver data is not enough: %zu (%zu)\n",
  164. sizeof(struct pcie_tx_ctrl_ndp),
  165. sizeof(tx_info->status.status_driver_data));
  166. return -ENOMEM;
  167. --
  168. 2.39.2