Parcourir la source

Fix some uninitialized variable compiler warnings

Guido Aulisi il y a 2 ans
Parent
commit
ea1f158906
5 fichiers modifiés avec 10 ajouts et 9 suppressions
  1. 1 1
      lib/parse_ini.c
  2. 4 4
      plugins-root/check_icmp.c
  3. 1 1
      plugins/check_disk.c
  4. 2 2
      plugins/check_load.c
  5. 2 1
      plugins/check_ntp_peer.c

+ 1 - 1
lib/parse_ini.c

@@ -118,7 +118,7 @@ static void parse_locator(const char *locator, const char *def_stanza, np_ini_in
 np_arg_list* np_get_defaults(const char *locator, const char *default_section){
 	FILE *inifile=NULL;
 	np_arg_list *defaults=NULL;
-	np_ini_info i;
+	np_ini_info i = {NULL, NULL};
 	struct stat fstat;
 	bool is_suid_set = np_suid();
 

+ 4 - 4
plugins-root/check_icmp.c

@@ -969,12 +969,12 @@ static void run_checks() {
 /*		icmp header                : 28 bytes */
 /*		icmp echo reply            : the rest */
 static int wait_for_reply(int sock, u_int t) {
-  int n, hlen;
+  int n, hlen = 0;
   static unsigned char buf[4096];
   struct sockaddr_storage resp_addr;
   union ip_hdr *ip;
   union icmp_packet packet;
-  struct rta_host *host;
+  struct rta_host *host = NULL;
   struct icmp_ping_data data;
   struct timeval wait_start, now;
   u_int tdiff, i, per_pkt_wait;
@@ -1700,8 +1700,8 @@ static u_int get_timevaldiff(struct timeval *early, struct timeval *later) {
 
 static int add_target_ip(char *arg, struct sockaddr_storage *in) {
   struct rta_host *host;
-  struct sockaddr_in *sin, *host_sin;
-  struct sockaddr_in6 *sin6, *host_sin6;
+  struct sockaddr_in *sin = NULL, *host_sin;
+  struct sockaddr_in6 *sin6 = NULL, *host_sin6;
 
   if (address_family == AF_INET) {
     sin = (struct sockaddr_in *)in;

+ 1 - 1
plugins/check_disk.c

@@ -233,7 +233,7 @@ main (int argc, char **argv)
   int temp_result2;
 
   struct mount_entry *me;
-  struct mount_entry *last_me;
+  struct mount_entry *last_me = NULL;
   struct fs_usage fsp, tmpfsp;
   struct parameter_list *temp_list, *path;
 

+ 2 - 2
plugins/check_load.c

@@ -101,7 +101,7 @@ get_threshold(char *arg, double *th)
 int
 main (int argc, char **argv)
 {
-	int result;
+	int result = 0;
 	int i, j;
 	long numcpus;
 
@@ -356,7 +356,7 @@ int cmpstringp(const void *p1, const void *p2) {
 #ifdef PS_USES_PROCETIME
 	char procetime[MAX_INPUT_BUFFER] = { '\0' };
 #endif /* PS_USES_PROCETIME */
-	char *procprog;
+	char *procprog = NULL;
 	char *proc_cgroup_hierarchy;
 	int pos;
 	sscanf (* (char * const *) p1, PS_FORMAT, PS_VARLIST);

+ 2 - 1
plugins/check_ntp_peer.c

@@ -560,7 +560,8 @@ char *perfd_truechimers (int num_truechimers)
 }
 
 int main(int argc, char *argv[]){
-	int result, offset_result, stratum, num_truechimers, oresult, jresult, sresult, tresult;
+	int result, offset_result, stratum, num_truechimers, oresult;
+	int jresult = STATE_OK, sresult = STATE_OK, tresult = STATE_OK;
 	double offset=0, jitter=0;
 	char *result_line, *perfdata_line;