]> Savannah Git Hosting - gnulib.git/commitdiff
getloadavg: Write NULL for the null pointer.
authorBruno Haible <bruno@clisp.org>
Sun, 3 Mar 2019 18:36:14 +0000 (19:36 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 10 Mar 2019 03:40:29 +0000 (04:40 +0100)
Reported by Michal Privoznik <mprivozn@redhat.com>.

* lib/getloadavg.c (getloadavg): Write NULL instead of 0.

ChangeLog
lib/getloadavg.c

index bfb9ffc208caf9f1863a412f054cc4d5044badf7..4efd9bccc44ed053a3cc77adb73cef1182bbb6a0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-03-03  Bruno Haible  <bruno@clisp.org>
+
+       getloadavg: Write NULL for the null pointer.
+       Reported by Michal Privoznik <mprivozn@redhat.com>.
+       * lib/getloadavg.c (getloadavg): Write NULL instead of 0.
+
 2019-02-28  Michal Privoznik  <mprivozn@redhat.com>
 
        alloca, tsearch-tests: Write NULL for the null pointer.
index 353664777fb3112bf71ec78ec0497ac838d60968..08c14efcfce049778fb87acde71fd10707729ae3 100644 (file)
@@ -424,17 +424,17 @@ getloadavg (double loadavg[], int nelem)
   int saved_errno;
 
   kc = kstat_open ();
-  if (kc == 0)
+  if (kc == NULL)
     return -1;
   ksp = kstat_lookup (kc, "unix", 0, "system_misc");
-  if (ksp == 0)
+  if (ksp == NULL)
     return -1;
   if (kstat_read (kc, ksp, 0) == -1)
     return -1;
 
 
   kn = kstat_data_lookup (ksp, "avenrun_1min");
-  if (kn == 0)
+  if (kn == NULL)
     {
       /* Return -1 if no load average information is available.  */
       nelem = 0;
@@ -447,14 +447,14 @@ getloadavg (double loadavg[], int nelem)
   if (nelem >= 2)
     {
       kn = kstat_data_lookup (ksp, "avenrun_5min");
-      if (kn != 0)
+      if (kn != NULL)
         {
           loadavg[elem++] = (double) kn->value.ul / FSCALE;
 
           if (nelem >= 3)
             {
               kn = kstat_data_lookup (ksp, "avenrun_15min");
-              if (kn != 0)
+              if (kn != NULL)
                 loadavg[elem++] = (double) kn->value.ul / FSCALE;
             }
         }
@@ -895,7 +895,7 @@ getloadavg (double loadavg[], int nelem)
       /* We pass 0 for the kernel, corefile, and swapfile names
          to use the currently running kernel.  */
       kd = kvm_open (0, 0, 0, O_RDONLY, 0);
-      if (kd != 0)
+      if (kd != NULL)
         {
           /* nlist the currently running kernel.  */
           kvm_nlist (kd, name_list);