MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fetch_stats_internal

Function fetch_stats_internal

tools/netstat/main.c:665–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

663}
664
665static int
666fetch_stats_internal(const char *sysctlname, u_long off, void *stats,
667 size_t len, kreadfn_t kreadfn, int zero)
668{
669 int error;
670
671 if (live) {
672 memset(stats, 0, len);
673 if (zero)
674 error = sysctlbyname(sysctlname, NULL, NULL, stats,
675 len);
676 else
677 error = sysctlbyname(sysctlname, stats, &len, NULL, 0);
678 if (error == -1 && errno != ENOENT)
679 xo_warn("sysctl %s", sysctlname);
680 } else {
681 if (off == 0)
682 return (1);
683 error = kreadfn(off, stats, len);
684 }
685 return (error);
686}
687
688int
689fetch_stats(const char *sysctlname, u_long off, void *stats,

Callers 2

fetch_statsFunction · 0.85
fetch_stats_roFunction · 0.85

Calls 3

memsetFunction · 0.85
sysctlbynameFunction · 0.85
xo_warnFunction · 0.85

Tested by

no test coverage detected