Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jun 2018 11:12:52 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r335049 - head/usr.bin/top
Message-ID:  <201806131112.w5DBCqo2066427@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Wed Jun 13 11:12:52 2018
New Revision: 335049
URL: https://svnweb.freebsd.org/changeset/base/335049

Log:
  top(1): remove unneeded logic
  
  - remove __pure annotations I added earlier for some functions. One
  writes to the the arguments as "out" pointers. The
  other reads from an array, which while const within the function might
  be mutated externally.
  - total_change is modified to be at 1, if previously 0, so no if check
  is needed.

Modified:
  head/usr.bin/top/utils.c

Modified: head/usr.bin/top/utils.c
==============================================================================
--- head/usr.bin/top/utils.c	Wed Jun 13 11:11:33 2018	(r335048)
+++ head/usr.bin/top/utils.c	Wed Jun 13 11:12:52 2018	(r335049)
@@ -122,7 +122,7 @@ digits(int val)
  * string_index(string, array) - find string in array and return index
  */
 
-int __pure
+int
 string_index(const char *string, const char * const *array)
 {
     size_t i = 0;
@@ -175,7 +175,7 @@ argparse(char *line, int *cntp)
  *	useful on for calculating cpu state percentages.
  */
 
-long __pure
+long
 percentages(int cnt, int *out, long *new, long *old, long *diffs)
 {
     int i;
@@ -210,13 +210,10 @@ percentages(int cnt, int *out, long *new, long *old, l
     /* calculate percentages based on overall change, rounding up */
     half_total = total_change / 2l;
 
-    /* Do not divide by 0. Causes Floating point exception */
-    if(total_change) {
-        for (i = 0; i < cnt; i++)
-        {
-          *out++ = (int)((*diffs++ * 1000 + half_total) / total_change);
-        }
-    }
+	for (i = 0; i < cnt; i++)
+	{
+		*out++ = (int)((*diffs++ * 1000 + half_total) / total_change);
+	}
 
     /* return the total in case the caller wants to use it */
     return(total_change);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806131112.w5DBCqo2066427>