Skip to content

Commit

Permalink
Move ifprop assignment more earlier
Browse files Browse the repository at this point in the history
We already get the attibutes of ifprop during getifprop() after
reading /proc/net/dev, thus remove the unnecessary second getter
in deviatsyst().

Signed-off-by: Fei Li <[email protected]>
  • Loading branch information
ShirleyFei committed Feb 21, 2023
1 parent 416e955 commit c44c37a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
15 changes: 0 additions & 15 deletions deviate.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include <string.h>

#include "atop.h"
#include "ifprop.h"
#include "photoproc.h"
#include "photosyst.h"

Expand Down Expand Up @@ -617,7 +616,6 @@ deviatsyst(struct sstat *cur, struct sstat *pre, struct sstat *dev,
{
register int i, j;
count_t *cdev, *ccur, *cpre;
struct ifprop ifprop;

dev->cpu.nrcpu = cur->cpu.nrcpu;
dev->cpu.devint = subcount(cur->cpu.devint, pre->cpu.devint);
Expand Down Expand Up @@ -887,19 +885,6 @@ deviatsyst(struct sstat *cur, struct sstat *pre, struct sstat *dev,
/*
** calculate deviations for interfaces
*/
for (i=0; cur->intf.intf[i].name[0]; i++)
{
// fill current properties for each valid interface
strcpy(ifprop.name, cur->intf.intf[i].name);

getifprop(&ifprop);

cur->intf.intf[i].type = ifprop.type;
cur->intf.intf[i].speed = ifprop.speed;
cur->intf.intf[i].speedp = ifprop.speed;
cur->intf.intf[i].duplex = ifprop.fullduplex;
}

if (pre->intf.intf[0].name[0] == '\0') /* first sample? */
{
for (i=0; cur->intf.intf[i].name[0]; i++)
Expand Down
5 changes: 5 additions & 0 deletions photosyst.c
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,11 @@ photosyst(struct sstat *si)
if (!getifprop(&ifprop))
continue;

si->intf.intfns[0].intf[i].type = ifprop.type;
si->intf.intfns[0].intf[i].speed = ifprop.speed;
si->intf.intfns[0].intf[i].speedp = ifprop.speed;
si->intf.intfns[0].intf[i].duplex = ifprop.fullduplex;

/*
** accept this interface but skip the remaining
** interfaces because we reached the total number
Expand Down

0 comments on commit c44c37a

Please sign in to comment.