Преглед изворни кода

Merge pull request #726 from efuss/fix-exclude-process

Some stylistic fixes to --exclude-process
aaronagios пре 1 година
родитељ
комит
da76d59767
1 измењених фајлова са 26 додато и 27 уклоњено
  1. 26 27
      plugins/check_procs.c

+ 26 - 27
plugins/check_procs.c

@@ -97,8 +97,8 @@ float pcpu;
 char *statopts;
 char *prog;
 char *exclude_progs;
-char ** exclude_progs_arr = NULL;
-char exclude_progs_counter = 0; 
+char **exclude_progs_arr = NULL;
+int exclude_progs_counter = 0;
 char *cgroup_hierarchy;
 char *args;
 char *input_filename = NULL;
@@ -275,23 +275,22 @@ main (int argc, char **argv)
 			}
 
 			/* Ignore excluded processes by name */
-			if(options & EXCLUDE_PROGS) {
-			  int found = 0;
-			  int i = 0;
-			 
-			  
-			  for(i=0; i < (exclude_progs_counter); i++) {
-			    if(!strcmp(procprog, exclude_progs_arr[i])) {
-			      found = 1;
-			    }
-			  }
-			  if(found == 0) {
-			    resultsum |= EXCLUDE_PROGS;
-			  }else
-			  {
-                            if(verbose >= 3)
-			      printf("excluding - by ignorelist\n");
-                          }
+			if (options & EXCLUDE_PROGS) {
+				int found = 0;
+				int i = 0;
+
+				for (i = 0; i < exclude_progs_counter; i++) {
+					if (!strcmp(procprog, exclude_progs_arr[i])) {
+						found = 1;
+						break;
+					}
+				}
+				if (found == 0) {
+					resultsum |= EXCLUDE_PROGS;
+				} else {
+					if (verbose >= 3)
+						printf("excluding - by ignorelist\n");
+				}
 			}
 
 			/* filter kernel threads (childs of KTHREAD_PARENT)*/
@@ -573,18 +572,18 @@ process_arguments (int argc, char **argv)
 			options |= PROG;
 			break;
 		case 'X':
-		        if(exclude_progs)
-			  break;
+		        if (exclude_progs)
+				break;
 			else
-			  exclude_progs = optarg;
+				exclude_progs = optarg;
 			xasprintf (&fmt, _("%s%sexclude progs '%s'"), (fmt ? fmt : ""), (options ? ", " : ""),
-				   exclude_progs);
+			           exclude_progs);
 			char *p = strtok(exclude_progs, ",");
 
-			while(p){
-			  exclude_progs_arr = realloc(exclude_progs_arr, sizeof(char*) * ++exclude_progs_counter);
-			  exclude_progs_arr[exclude_progs_counter-1] = p;
-			  p = strtok(NULL, ",");
+			while (p) {
+				exclude_progs_arr = realloc(exclude_progs_arr, sizeof(char*) * ++exclude_progs_counter);
+				exclude_progs_arr[exclude_progs_counter - 1] = p;
+				p = strtok(NULL, ",");
 			}
 
 			options |= EXCLUDE_PROGS;