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.
This commit is contained in:
parent
a5185adeb6
commit
f764243341
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=335049
@ -122,7 +122,7 @@ digits(int val)
|
|||||||
* string_index(string, array) - find string in array and return index
|
* string_index(string, array) - find string in array and return index
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int __pure
|
int
|
||||||
string_index(const char *string, const char * const *array)
|
string_index(const char *string, const char * const *array)
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
@ -175,7 +175,7 @@ argparse(char *line, int *cntp)
|
|||||||
* useful on for calculating cpu state percentages.
|
* useful on for calculating cpu state percentages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
long __pure
|
long
|
||||||
percentages(int cnt, int *out, long *new, long *old, long *diffs)
|
percentages(int cnt, int *out, long *new, long *old, long *diffs)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -210,13 +210,10 @@ percentages(int cnt, int *out, long *new, long *old, long *diffs)
|
|||||||
/* calculate percentages based on overall change, rounding up */
|
/* calculate percentages based on overall change, rounding up */
|
||||||
half_total = total_change / 2l;
|
half_total = total_change / 2l;
|
||||||
|
|
||||||
/* Do not divide by 0. Causes Floating point exception */
|
for (i = 0; i < cnt; i++)
|
||||||
if(total_change) {
|
{
|
||||||
for (i = 0; i < cnt; i++)
|
*out++ = (int)((*diffs++ * 1000 + half_total) / total_change);
|
||||||
{
|
}
|
||||||
*out++ = (int)((*diffs++ * 1000 + half_total) / total_change);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* return the total in case the caller wants to use it */
|
/* return the total in case the caller wants to use it */
|
||||||
return(total_change);
|
return(total_change);
|
||||||
|
Loading…
Reference in New Issue
Block a user