Skip to content

Commit

Permalink
gcov: add missing gcov.h includes
Browse files Browse the repository at this point in the history
Fixes the following "implicit declaration" warning (13 occurrences in
total) when building with gcov support:

    $ pacman -Q gcc10
    gcc10 1:10.2.0-3
    $ CC=gcc-10 && export CC
    $ ./configure --prefix=/usr --enable-apparmor --enable-gcov >/dev/null
    $ make >/dev/null
    appimage.c: In function ‘appimage_set’:
    appimage.c:140:2: warning: implicit declaration of function ‘__gcov_flush’ [-Wimplicit-function-declaration]
      140 |  __gcov_flush();
          |  ^~~~~~~~~~~~
    interface.c: In function ‘print_sandbox’:
    interface.c:149:3: warning: implicit declaration of function ‘__gcov_flush’ [-Wimplicit-function-declaration]
      149 |   __gcov_flush();
          |   ^~~~~~~~~~~~
    netstats.c: In function ‘netstats’:
    netstats.c:246:4: warning: implicit declaration of function ‘__gcov_flush’ [-Wimplicit-function-declaration]
      246 |    __gcov_flush();
          |    ^~~~~~~~~~~~
    [...]

Note: The commands above were executed from makepkg, while building
firejail-git from the AUR.

Note2: gcc-10 was used because the build fails with the current gcc
version (11.1.0) on Artix Linux.  The failure happens because
__gcov_flush was removed on gcc 11.1.0[1]; this will be addressed later.

Note3: The following command helped find the affected files:

    $ git grep -Fl __gcov -- src

[1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=811b7636cb8c10f1a550a76242b5666c7ae36da2
  • Loading branch information
kmk3 committed Jun 18, 2021
1 parent e770ab6 commit 31557e9
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/firejail/appimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include <linux/loop.h>
#include <errno.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

static char *devloop = NULL; // device file
static long unsigned size = 0; // offset into appimage file
#define MAXBUF 4096
Expand Down
3 changes: 3 additions & 0 deletions src/firejail/chroot.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#define O_PATH 010000000
#endif

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

// exit if error
void fs_check_chroot_dir(void) {
Expand Down
4 changes: 4 additions & 0 deletions src/firejail/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#define O_PATH 010000000
#endif

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

#define MAX_BUF 4096
#define EMPTY_STRING ("")
// check noblacklist statements not matched by a proper blacklist in disable-*.inc files
Expand Down
3 changes: 3 additions & 0 deletions src/firejail/fs_mkdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include <sys/wait.h>
#include <string.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

static void check(const char *fname) {
// manufacture /run/user directory
Expand Down
4 changes: 4 additions & 0 deletions src/firejail/ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
//#include <stdio.h>
//#include <stdlib.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

// uid/gid cache
static uid_t c_uid = 0;
static char *c_uid_name = NULL;
Expand Down
4 changes: 4 additions & 0 deletions src/firejail/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
#define O_PATH 010000000
#endif

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

#ifdef __ia64__
/* clone(2) has a different interface on ia64, as it needs to know
the size of the stack */
Expand Down
5 changes: 5 additions & 0 deletions src/firejail/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
#include "../include/syscall.h"
#include <dirent.h>
#include <sys/stat.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

extern char *xephyr_screen;

#define MAX_READ 8192 // line buffer for profile files
Expand Down
4 changes: 4 additions & 0 deletions src/firejail/rlimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include <sys/time.h>
#include <sys/resource.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

void set_rlimits(void) {
EUID_ASSERT();
// resource limits
Expand Down
3 changes: 3 additions & 0 deletions src/firejail/sandbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
#include <sys/apparmor.h>
#endif

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

static int force_nonewprivs = 0;

Expand Down
4 changes: 4 additions & 0 deletions src/firejail/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#include <linux/openat2.h>
#endif

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

#define MAX_GROUPS 1024
#define MAXBUF 4098
#define EMPTY_STRING ("")
Expand Down
4 changes: 4 additions & 0 deletions src/firemon/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
//#include <net/route.h>
//#include <linux/if_bridge.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

// print IP addresses for all interfaces
static void net_ifprint(void) {
uint32_t ip;
Expand Down
4 changes: 4 additions & 0 deletions src/firemon/netstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include <sys/stat.h>
#include <unistd.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

#define MAXBUF 4096

// ip -s link: device stats
Expand Down
4 changes: 4 additions & 0 deletions src/firemon/procevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include <fcntl.h>
#include <sys/uio.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

#define PIDS_BUFLEN 4096
#define SERVER_PORT 889 // 889-899 is left unassigned by IANA

Expand Down
4 changes: 4 additions & 0 deletions src/firemon/top.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include <sys/stat.h>
#include <unistd.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#endif

static unsigned pgs_rss = 0;
static unsigned pgs_shared = 0;
static unsigned clocktick = 0;
Expand Down

0 comments on commit 31557e9

Please sign in to comment.