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); _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"