]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - vendor.c
iw: document handler return value 1 as HANDLER_RET_USAGE
[thirdparty/iw.git] / vendor.c
index 5a693753f9498890309ab3376a167a2273c575de..279aac50727d941c5c0afe14aff4792c49604d7a 100644 (file)
--- a/vendor.c
+++ b/vendor.c
@@ -1,4 +1,3 @@
-#include <net/if.h>
 #include <errno.h>
 #include <string.h>
 
@@ -15,7 +14,8 @@ SECTION(vendor);
 
 static int read_file(FILE *file, char *buf, size_t size)
 {
-       int data, count = 0;
+       size_t count = 0;
+       int data;
 
        while ((data = fgetc(file)) != EOF) {
                if (count >= size)
@@ -27,10 +27,10 @@ static int read_file(FILE *file, char *buf, size_t size)
        return count;
 }
 
-static int read_hex(int argc, char **argv, char *buf, size_t size)
+static int read_hex(unsigned int argc, char **argv, char *buf, size_t size)
 {
-       int i, res;
-       unsigned int data;
+       unsigned int i, data;
+       int res;
 
        if (argc > size)
                return -EINVAL;
@@ -56,15 +56,19 @@ static int handle_vendor(struct nl80211_state *state,
        FILE *file = NULL;
 
        if (argc < 3)
-               return -EINVAL;
+               return 1;
 
        res = sscanf(argv[0], "0x%x", &oui);
-       if (res != 1)
-               return -EINVAL;
+       if (res != 1) {
+               printf("Vendor command must start with 0x\n");
+               return 2;
+       }
 
        res = sscanf(argv[1], "0x%x", &subcmd);
-       if (res != 1)
-               return -EINVAL;
+       if (res != 1) {
+               printf("Sub command must start with 0x\n");
+               return 2;
+       }
 
        if (!strcmp(argv[2], "-"))
                file = stdin;