mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-26 16:41:25 +00:00
tools: bpftool: add pointer to file argument to print_hex()
Make print_hex() able to print to any file instead of standard output only, and rename it to fprint_hex(). The function can now be called with the info() macro, for example, without splitting the output between standard and error outputs. Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
f3ae608edb
commit
9cbe1f581d
4 changed files with 17 additions and 17 deletions
|
@ -100,7 +100,7 @@ bool is_prefix(const char *pfx, const char *str)
|
|||
return !memcmp(str, pfx, strlen(pfx));
|
||||
}
|
||||
|
||||
void print_hex(void *arg, unsigned int n, const char *sep)
|
||||
void fprint_hex(FILE *f, void *arg, unsigned int n, const char *sep)
|
||||
{
|
||||
unsigned char *data = arg;
|
||||
unsigned int i;
|
||||
|
@ -111,13 +111,13 @@ void print_hex(void *arg, unsigned int n, const char *sep)
|
|||
if (!i)
|
||||
/* nothing */;
|
||||
else if (!(i % 16))
|
||||
printf("\n");
|
||||
fprintf(f, "\n");
|
||||
else if (!(i % 8))
|
||||
printf(" ");
|
||||
fprintf(f, " ");
|
||||
else
|
||||
pfx = sep;
|
||||
|
||||
printf("%s%02hhx", i ? pfx : "", data[i]);
|
||||
fprintf(f, "%s%02hhx", i ? pfx : "", data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue