Przeglądaj źródła

feat: added changes to code structure recommended by @nsoggia on github

root 1 rok temu
rodzic
commit
1614df281f
1 zmienionych plików z 4 dodań i 6 usunięć
  1. 4 6
      plugins/check_snmp.c

+ 4 - 6
plugins/check_snmp.c

@@ -504,14 +504,12 @@ main (int argc, char **argv)
 		/* Make some special values,like Timeticks numeric only if a threshold is defined */
 		if (thlds[i]->warning || thlds[i]->critical || calculate_rate || is_ticks || offset != 0.0 || multiplier != 1.0) {
 			/* Find the first instance of the '(' character - the value of the OID should be contained in parens */
-			if (ptr = strpbrk(show, "(")) {
+			if ((ptr = strpbrk(show, "(")) != NULL) { /* Timetick */
 				ptr++; /* Move to the first character after the '(' */
-			} else {
-				ptr = strpbrk(show, "-0123456789");
-			}
-			if (ptr == NULL)
+			} else if ((ptr = strpbrk(show, "-0123456789")) == NULL) { /* Counter, gauge, or integer */
 				die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show);
-			
+			}
+
 			while (i >= response_size) {
 				response_size += OID_COUNT_STEP;
 				response_value = realloc(response_value, response_size * sizeof(*response_value));