Reduce scope for some variables
authorRomain Forlot <romain.forlot@iot.bzh>
Mon, 4 Sep 2017 12:35:48 +0000 (14:35 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Thu, 13 Dec 2018 13:12:02 +0000 (14:12 +0100)
Change-Id: Ic89421054a83709eec6afaa22dbb4373bcff9b19
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
filescan-utils.c

index 3eb1b50..dbbccc3 100644 (file)
@@ -89,8 +89,8 @@ PUBLIC const char *GetMidleName(const char*name) {
     char *fullname = strdup(name);
 
     for (int idx = 0; fullname[idx] != '\0'; idx++) {
-        int start;
         if (fullname[idx] == '-') {
+            int start;
             start = idx + 1;
             for (int jdx = start; ; jdx++) {
                 if (fullname[jdx] == '-' || fullname[jdx] == '.' || fullname[jdx] == '\0') {
@@ -106,13 +106,13 @@ PUBLIC const char *GetMidleName(const char*name) {
 }
 
 PUBLIC const char *GetBinderName() {
-    char psName[17];
     static char *binderName=NULL;
 
     if (binderName) return binderName;
 
     binderName= getenv("AFB_BINDER_NAME");
     if (!binderName) {
+        char psName[17];
         // retrieve binder name from process name afb-name-trailer
         prctl(PR_GET_NAME, psName,NULL,NULL,NULL);
         binderName=(char*)GetMidleName(psName);