Use defined constant for max length
authorCheoleun Moon <chleun.moon@samsung.com>
Fri, 3 Apr 2020 05:38:17 +0000 (14:38 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Fri, 3 Apr 2020 05:38:17 +0000 (14:38 +0900)
test/wifi-aware-test.c

index 8060a606780a2b6f8e787b6a7eb1862f67028f79..1c8070d15b3041506ddebec2093a12a2b8b12897 100644 (file)
 #define MAX_SPECIFIC_INFO_LEN 1024
 #define MAX_MATCH_FILTER_LEN 255
 
+#define STR_(X) #X
+#define STR(X) STR_(X)
+
 #define MAX_PSK_LEN 63
 #define PMK_LEN 32
 #define IPV6_ADDRESS_LEN 39
@@ -443,7 +446,7 @@ static int __set_match_filter(unsigned char match_filter[MAX_MATCH_FILTER_LEN +
                        return -1;
                }
                printf("%d match filter value: ", i);
-               if (scanf("%255s", filter) < 0)
+               if (scanf("%" STR(MAX_MATCH_FILTER_LEN) "s", filter) < 0)
                        return -1;
                if (len != strlen(filter)) {
                        printf("The length of filter value is not %d\n", len);
@@ -469,7 +472,7 @@ static void __set_publish_config(wifi_aware_publish_h publish)
        int set_mf = 0;
 
        printf("Service Name: ");
-       if (scanf(" %255s", service_name) < 0)
+       if (scanf(" %" STR(MAX_SERVICE_NAME_LEN) "s", service_name) < 0)
                return;
 
        ret = wifi_aware_publish_set_service_name(publish,
@@ -492,7 +495,7 @@ static void __set_publish_config(wifi_aware_publish_h publish)
                return;
        
        if (set_info == 1) {
-               if (scanf(" %1024s", str_specific_info) < 0)
+               if (scanf(" %" STR(MAX_SPECIFIC_INFO_LEN) "s", str_specific_info) < 0)
                        return;
 
                len = strlen(str_specific_info);
@@ -698,7 +701,7 @@ static void __set_subscribe_config(wifi_aware_subscribe_h subscribe)
        int set_mf = 0;
 
        printf("Service Name: ");
-       if (scanf("%255s", service_name) < 0)
+       if (scanf("%" STR(MAX_SERVICE_NAME_LEN) "s", service_name) < 0)
                return;
 
        ret = wifi_aware_subscribe_set_service_name(subscribe,
@@ -721,7 +724,7 @@ static void __set_subscribe_config(wifi_aware_subscribe_h subscribe)
                return;
        
        if (set_info == 1) {
-               if (scanf(" %1024s", str_specific_info) < 0)
+               if (scanf(" %" STR(MAX_SPECIFIC_INFO_LEN) "s", str_specific_info) < 0)
                        return;
 
                len = strlen(str_specific_info);