]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: small cleanup for the sizer code
authorJohannes Berg <johannes.berg@intel.com>
Thu, 28 Feb 2019 21:28:19 +0000 (22:28 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 28 Feb 2019 21:28:48 +0000 (22:28 +0100)
We should use a signed variable if we subtract and potentially
end up with a negative value.

Additionally, we directly reference these variables so don't
need __attribute__((used)).

Change-Id: I78c2a5706dce9c90595284cf5e1d9d6f6fa1879e
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
iw.c

diff --git a/iw.c b/iw.c
index afc811892188d5dc094df26c9d973ec88b7221e3..40f8f6ea7d69ca2c92449de533cf1872cd15bb5b 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -558,8 +558,8 @@ int handle_cmd(struct nl80211_state *state, enum id_input idby,
  * be how they get packed and that can be used to iterate the __cmd section
  * as well.
  */
-static struct cmd sizer1 __attribute__((used,section("__sizer"))) = {};
-static struct cmd sizer2 __attribute__((used,section("__sizer"))) = {};
+static struct cmd sizer1 __attribute__((section("__sizer"))) = {};
+static struct cmd sizer2 __attribute__((section("__sizer"))) = {};
 
 int main(int argc, char **argv)
 {
@@ -568,7 +568,7 @@ int main(int argc, char **argv)
        const struct cmd *cmd = NULL;
 
        /* calculate command size including padding */
-       cmd_size = labs((uintptr_t)&sizer2 - (uintptr_t)&sizer1);
+       cmd_size = labs((long)&sizer2 - (long)&sizer1);
        /* strip off self */
        argc--;
        argv0 = *argv++;