Minor optimization.
authorOleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
Fri, 29 Aug 2014 09:48:01 +0000 (12:48 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 7 Sep 2014 22:40:51 +0000 (00:40 +0200)
ncl/ncl.c

index 53ad3d9..214e603 100644 (file)
--- a/ncl/ncl.c
+++ b/ncl/ncl.c
@@ -260,25 +260,20 @@ static void ncl_prv_parse_script_file(char *scriptFileStr)
                return;
        }
 
-       do {
-               /* Reading command line script file */
-               nbRead = getline(&cmdLineStr, &cmdLineSize, scriptFile);
-               if (nbRead > 0) {
-                               /* Executing command line */
-                               NCL_CMD_PRINT("$$$$$$$$$$$$$$$$$$$$$$$$$'\n");
-                               NCL_CMD_PRINT("Executing '%s'\n", cmdLineStr);
-                               NCL_CMD_PRINT("$$$$$$$$$$$$$$$$$$$$$$$$$'\n");
-                               gNclCtx.errOnExit = ncl_exec(cmdLineStr);
-
-                               while (g_main_context_pending(NULL))
-                                       g_main_context_iteration(NULL, FALSE);
-               }
-               /* Freeing command line */
-               if (cmdLineStr != NULL) {
-                       free(cmdLineStr);
-                       cmdLineStr = NULL;
-               }
-       } while (nbRead > 0 && gNclCtx.errOnExit == NCLERR_NOERROR);
+       gNclCtx.errOnExit = NCLERR_NOERROR;
+
+       while ((nbRead = getline(&cmdLineStr, &cmdLineSize, scriptFile)) != -1
+                       && gNclCtx.errOnExit == NCLERR_NOERROR) {
+
+               NCL_CMD_PRINT("$$$$$$$$$$$$$$$$$$$$$$$$$'\n");
+               NCL_CMD_PRINT("Executing '%s'\n", cmdLineStr);
+               NCL_CMD_PRINT("$$$$$$$$$$$$$$$$$$$$$$$$$'\n");
+               gNclCtx.errOnExit = ncl_exec(cmdLineStr);
+
+               while (g_main_context_pending(NULL))
+                       g_main_context_iteration(NULL, FALSE);
+       }
+
        fclose(scriptFile);
 }