jool: fix compilation warning

Add patch fixing compilation warning due to wrong cast.
Fix compilation warning:
/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-mips-openwrt-linux-musl_musl/linux-lantiq_xrx200/jool-4.1.8/src/mod/common/xlator.c: In function 'offset_equals':
/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-mips-openwrt-linux-musl_musl/linux-lantiq_xrx200/jool-4.1.8/src/mod/common/xlator.c:878:32: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  878 |         return (offset->ns == ((__u64)instance->jool.ns & 0xFFFFFFFF))
      |                                ^
cc1: all warnings being treated as errors

In file included from ./include/linux/kernel.h:19,
                 from ./include/linux/skbuff.h:13,
                 from /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-mips-openwrt-linux-musl_musl/linux-lantiq_xrx200/jool-4.1.8/src/mod/common/../../mod/common/skbuff.h:4,
                 from /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-mips-openwrt-linux-musl_musl/linux-lantiq_xrx200/jool-4.1.8/src/mod/common/skbuff.c:1:
/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-mips-openwrt-linux-musl_musl/linux-lantiq_xrx200/jool-4.1.8/src/mod/common/skbuff.c: In function 'print_skb_fields':
./include/linux/kern_levels.h:5:25: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Werror=format=]
    5 | #define KERN_SOH        "\001"          /* ASCII Start Of Header */
      |                         ^~~~~~
./include/linux/printk.h:422:25: note: in definition of macro 'printk_index_wrap'
  422 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                         ^~~~
./include/linux/printk.h:535:9: note: in expansion of macro 'printk'
  535 |         printk(KERN_CONT fmt, ##__VA_ARGS__)
      |         ^~~~~~
./include/linux/kern_levels.h:24:25: note: in expansion of macro 'KERN_SOH'
   24 | #define KERN_CONT       KERN_SOH "c"
      |                         ^~~~~~~~
./include/linux/printk.h:535:16: note: in expansion of macro 'KERN_CONT'
  535 |         printk(KERN_CONT fmt, ##__VA_ARGS__)
      |                ^~~~~~~~~
/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-mips-openwrt-linux-musl_musl/linux-lantiq_xrx200/jool-4.1.8/src/mod/common/skbuff.c:38:17: note: in expansion of macro 'pr_cont'
   38 |                 pr_cont(text "\n", ##__VA_ARGS__); \
      |                 ^~~~~~~
/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-mips-openwrt-linux-musl_musl/linux-lantiq_xrx200/jool-4.1.8/src/mod/common/skbuff.c:112:9: note: in expansion of macro 'print'
  112 |         print(tabs, "data:%ld", skb->data - skb->head);
      |         ^~~~~
./include/linux/kern_levels.h:5:25: error: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'sk_buff_data_t' {aka 'unsigned char *'} [-Werror=format=]
    5 | #define KERN_SOH        "\001"          /* ASCII Start Of Header */
      |                         ^~~~~~
./include/linux/printk.h:422:25: note: in definition of macro 'printk_index_wrap'
  422 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                         ^~~~
./include/linux/printk.h:535:9: note: in expansion of macro 'printk'
  535 |         printk(KERN_CONT fmt, ##__VA_ARGS__)
      |         ^~~~~~
./include/linux/kern_levels.h:24:25: note: in expansion of macro 'KERN_SOH'
   24 | #define KERN_CONT       KERN_SOH "c"
      |                         ^~~~~~~~
./include/linux/printk.h:535:16: note: in expansion of macro 'KERN_CONT'
  535 |         printk(KERN_CONT fmt, ##__VA_ARGS__)
      |                ^~~~~~~~~
/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-mips-openwrt-linux-musl_musl/linux-lantiq_xrx200/jool-4.1.8/src/mod/common/skbuff.c:38:17: note: in expansion of macro 'pr_cont'
   38 |                 pr_cont(text "\n", ##__VA_ARGS__); \
      |                 ^~~~~~~
/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-mips-openwrt-linux-musl_musl/linux-lantiq_xrx200/jool-4.1.8/src/mod/common/skbuff.c:113:9: note: in expansion of macro 'print'
  113 |         print(tabs, "tail:%u", skb->tail);
      |         ^~~~~
./include/linux/kern_levels.h:5:25: error: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'sk_buff_data_t' {aka 'unsigned char *'} [-Werror=format=]
    5 | #define KERN_SOH        "\001"          /* ASCII Start Of Header */
      |                         ^~~~~~
./include/linux/printk.h:422:25: note: in definition of macro 'printk_index_wrap'
  422 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                         ^~~~
./include/linux/printk.h:535:9: note: in expansion of macro 'printk'
  535 |         printk(KERN_CONT fmt, ##__VA_ARGS__)
      |         ^~~~~~
./include/linux/kern_levels.h:24:25: note: in expansion of macro 'KERN_SOH'
   24 | #define KERN_CONT       KERN_SOH "c"
      |                         ^~~~~~~~
./include/linux/printk.h:535:16: note: in expansion of macro 'KERN_CONT'
  535 |         printk(KERN_CONT fmt, ##__VA_ARGS__)
      |                ^~~~~~~~~
/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-mips-openwrt-linux-musl_musl/linux-lantiq_xrx200/jool-4.1.8/src/mod/common/skbuff.c:38:17: note: in expansion of macro 'pr_cont'
   38 |                 pr_cont(text "\n", ##__VA_ARGS__); \
      |                 ^~~~~~~
/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-mips-openwrt-linux-musl_musl/linux-lantiq_xrx200/jool-4.1.8/src/mod/common/skbuff.c:114:9: note: in expansion of macro 'print'
  114 |         print(tabs, "end:%u", skb->end);
      |         ^~~~~
cc1: all warnings being treated as errors

/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-mips-openwrt-linux-musl_musl/linux-lantiq_xrx200/jool-4.1.8/src/mod/common/nl/instance.c: In function 'serialize_instance':
/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-mips-openwrt-linux-musl_musl/linux-lantiq_xrx200/jool-4.1.8/src/mod/common/nl/instance.c:40:46: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
   40 |         error = nla_put_u32(skb, JNLAIE_NS, ((__u64)entry->ns) & 0xFFFFFFFF);
      |                                              ^
cc1: all warnings being treated as errors

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
This commit is contained in:
Christian Marangi 2023-05-15 00:28:56 +02:00
parent 53959d50fd
commit 89731e6f4d
No known key found for this signature in database
GPG Key ID: AC001D09ADBFEAD7
1 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,37 @@
--- a/src/mod/common/skbuff.c
+++ b/src/mod/common/skbuff.c
@@ -109,9 +109,9 @@ static void print_skb_fields(struct sk_buff *skb, unsigned int tabs)
print(tabs, "network_header:%u", skb->network_header);
print(tabs, "mac_header:%u", skb->mac_header);
print(tabs, "head:%p", skb->head);
- print(tabs, "data:%ld", skb->data - skb->head);
- print(tabs, "tail:%u", skb->tail);
- print(tabs, "end:%u", skb->end);
+ print(tabs, "data:%ld", (long int)(skb->data - skb->head));
+ print(tabs, "tail:%u", (unsigned int)skb->tail);
+ print(tabs, "end:%u", (unsigned int)skb->end);
}
static int truncated(unsigned int tabs)
--- a/src/mod/common/xlator.c
+++ b/src/mod/common/xlator.c
@@ -875,7 +875,7 @@ void xlator_put(struct xlator *jool)
static bool offset_equals(struct instance_entry_usr *offset,
struct jool_instance *instance)
{
- return (offset->ns == ((__u64)instance->jool.ns & 0xFFFFFFFF))
+ return (offset->ns == ((uintptr_t)instance->jool.ns & 0xFFFFFFFF))
&& (strcmp(offset->iname, instance->jool.iname) == 0);
}
--- a/src/mod/common/nl/instance.c
+++ b/src/mod/common/nl/instance.c
@@ -37,7 +37,7 @@ static int serialize_instance(struct xlator *entry, void *arg)
if (!root)
return 1;
- error = nla_put_u32(skb, JNLAIE_NS, ((__u64)entry->ns) & 0xFFFFFFFF);
+ error = nla_put_u32(skb, JNLAIE_NS, ((uintptr_t)entry->ns) & 0xFFFFFFFF);
if (error)
goto cancel;
error = nla_put_u8(skb, JNLAIE_XF, xlator_flags2xf(entry->flags));