Skip to content

Commit

Permalink
reallocarray: eliminate compilation warnings (iovisor#3798)
Browse files Browse the repository at this point in the history
there are compile warnings below for klockstat.

```bash
  CC       klockstat.o
klockstat.c: In function ‘print_stats’:
klockstat.c:396:12: warning: implicit declaration of function ‘reallocarray’; did you mean ‘realloc’? [-Wimplicit-function-declaration]
    stats = reallocarray(stats, stats_sz, sizeof(void *));
            ^~~~~~~~~~~~
            realloc
klockstat.c:396:10: warning: assignment to ‘struct stack_stat **’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
    stats = reallocarray(stats, stats_sz, sizeof(void *));
          ^
  BINARY   klockstat
```

Defining _GNU_SOURCE fixed the problem.
  • Loading branch information
Rtoax committed Jan 8, 2022
1 parent eab81d9 commit 96aaf15
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libbpf-tools/klockstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <stdlib.h>
#include <string.h>
#include <time.h>
Expand Down

0 comments on commit 96aaf15

Please sign in to comment.