fix some warnings
authorJosé Bollo <jose.bollo@iot.bzh>
Tue, 29 Dec 2015 14:23:40 +0000 (15:23 +0100)
committerJosé Bollo <jose.bollo@iot.bzh>
Tue, 29 Dec 2015 14:31:43 +0000 (15:31 +0100)
Change-Id: Ibcdc33feb279309633a78b51d59d26846b259003

src/afm-launch.c
src/wgtpkg-info.c
src/wgtpkg-zip.c

index 937366d..1f9907d 100644 (file)
@@ -107,25 +107,26 @@ static char **instantiate_arguments(const char **args, struct afm_launch_desc *d
 {
        const char **iter, *p, *v;
        char *data, **result, port[20], width[20], height[20], mini[3], c;
-       int n, s, x;
+       int n, s;
 
        /* init */
        mini[0] = '%';
        mini[2] = 0;
 
        /* loop that either compute the size and build the result */
-       n = s = x = 0;
+       data = NULL;
+       n = s = 0;
        for (;;) {
                iter = args;
                n = 0;
                while (*iter) {
                        p = *iter++;
-                       if (x)
+                       if (data)
                                result[n] = data;
                        n++;
                        while((c = *p++) != 0) {
                                if (c != '%') {
-                                       if (x)
+                                       if (data)
                                                *data++ = c;
                                        else
                                                s++;
@@ -133,7 +134,7 @@ static char **instantiate_arguments(const char **args, struct afm_launch_desc *d
                                        c = *p++;
                                        switch (c) {
                                        case 'I': v = FWK_ICON_DIR; break;
-                                       case 'P': if(!x) sprintf(port, "%d", params->port); v = port; break;
+                                       case 'P': if(!data) sprintf(port, "%d", params->port); v = port; break;
                                        case 'S': v = params->secret; break;
                                        case 'D': v = params->datadir; break;
                                        case 'r': v = desc->path; break;
@@ -144,23 +145,23 @@ static char **instantiate_arguments(const char **args, struct afm_launch_desc *d
                                        case 'm': v = desc->type; break;
                                        case 'n': v = desc->name; break;
                                        case 'p': v = "" /*desc->plugins*/; break;
-                                       case 'W': if(!x) sprintf(width, "%d", desc->width); v = width; break;
-                                       case 'H': if(!x) sprintf(height, "%d", desc->height); v = height; break;
+                                       case 'W': if(!data) sprintf(width, "%d", desc->width); v = width; break;
+                                       case 'H': if(!data) sprintf(height, "%d", desc->height); v = height; break;
                                        case '%': c = 0;
                                        default: mini[1] = c; v = mini; break;
                                        }
-                                       if (x)
+                                       if (data)
                                                data = stpcpy(data, v);
                                        else
                                                s += strlen(v);
                                }
                        }
-                       if (x)
+                       if (data)
                                *data++ = 0;
                        else
                                s++;
                }
-               if (x) {
+               if (data) {
                        result[n] = NULL;
                        return result;
                }
@@ -171,7 +172,6 @@ static char **instantiate_arguments(const char **args, struct afm_launch_desc *d
                        return NULL;
                }
                data = (char*)(&result[n + 1]);
-               x = 1;
        }
 }
 
index 67d4596..b2855b6 100644 (file)
@@ -16,8 +16,6 @@
  limitations under the License.
 */
 
-#define _BSD_SOURCE /* see readdir */
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <dirent.h>
index 8168fe7..4b87a41 100644 (file)
@@ -16,7 +16,7 @@
  limitations under the License.
 */
 
-#define _BSD_SOURCE /* see readdir */
+#define _DEFAULT_SOURCE
 
 #include <limits.h>
 #include <sys/types.h>
@@ -353,6 +353,7 @@ int zwrite(const char *zipfile)
 #else
 
 #include <sys/wait.h>
+#include <stdlib.h>
 
 extern char **environ;