Browse Source

zebra: fix warnings in forward proc

Check result of fgets(), and don't set variable that is
never used.
Stephen Hemminger 7 years ago
parent
commit
d7a083844d
1 changed files with 4 additions and 5 deletions
  1. 4 5
      zebra/ipforward_proc.c

+ 4 - 5
zebra/ipforward_proc.c

@@ -45,7 +45,6 @@ ipforward (void)
 {
   FILE *fp;
   int ipforwarding = 0;
-  char *pnt;
   char buf[10];
 
   fp = fopen (proc_net_snmp, "r");
@@ -59,8 +58,8 @@ ipforward (void)
   /* Get ip_statistics.IpForwarding : 
      1 => ip forwarding enabled 
      2 => ip forwarding off. */
-  pnt = fgets (buf, 6, fp);
-  sscanf (buf, "Ip: %d", &ipforwarding);
+  if (fgets (buf, 6, fp))
+    sscanf (buf, "Ip: %d", &ipforwarding);
 
   fclose(fp);
   
@@ -140,8 +139,8 @@ ipforward_ipv6 (void)
   if (fp == NULL)
     return -1;
 
-  fgets (buf, 2, fp);
-  sscanf (buf, "%d", &ipforwarding);
+  if (fgets (buf, 2, fp))
+    sscanf (buf, "%d", &ipforwarding);
 
   fclose (fp);
   return ipforwarding;