Skip to content

Commit

Permalink
Merge pull request #4373 from kmk3/gcov-fix-build-gcc11
Browse files Browse the repository at this point in the history
gcov: fix build failure with gcc 11.1.0
  • Loading branch information
netblue30 authored Jun 27, 2021
2 parents 0c2a5e3 + b408b20 commit 77e9d0d
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/firejail/appimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <errno.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

static char *devloop = NULL; // device file
Expand Down
2 changes: 1 addition & 1 deletion src/firejail/chroot.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#endif

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

// exit if error
Expand Down
2 changes: 1 addition & 1 deletion src/firejail/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#endif

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

#define MAX_BUF 4096
Expand Down
2 changes: 1 addition & 1 deletion src/firejail/fs_mkdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <string.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

static void check(const char *fname) {
Expand Down
2 changes: 1 addition & 1 deletion src/firejail/ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
//#include <stdlib.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

// uid/gid cache
Expand Down
2 changes: 1 addition & 1 deletion src/firejail/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#endif

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

#ifdef __ia64__
Expand Down
2 changes: 1 addition & 1 deletion src/firejail/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <sys/stat.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

extern char *xephyr_screen;
Expand Down
2 changes: 1 addition & 1 deletion src/firejail/rlimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <sys/resource.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

void set_rlimits(void) {
Expand Down
2 changes: 1 addition & 1 deletion src/firejail/sandbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#endif

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

static int force_nonewprivs = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/firejail/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#endif

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

#define MAX_GROUPS 1024
Expand Down
2 changes: 1 addition & 1 deletion src/firemon/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
//#include <linux/if_bridge.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

// print IP addresses for all interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/firemon/netstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <unistd.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

#define MAXBUF 4096
Expand Down
2 changes: 1 addition & 1 deletion src/firemon/procevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <sys/uio.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

#define PIDS_BUFLEN 4096
Expand Down
2 changes: 1 addition & 1 deletion src/firemon/top.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <unistd.h>

#ifdef HAVE_GCOV
#include <gcov.h>
#include "../include/gcov_wrapper.h"
#endif

static unsigned pgs_rss = 0;
Expand Down
40 changes: 40 additions & 0 deletions src/include/gcov_wrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2021 Firejail Authors
*
* This file is part of firejail project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef GCOV_WRAPPER_H
#define GCOV_WRAPPER_H

#include <gcov.h>

/*
* __gcov_flush was removed on gcc 11.1.0 (as it's no longer needed), but it
* appears to be the safe/"correct" way to do things on previous versions (as
* it ensured proper locking, which is now done elsewhere). Thus, keep using
* it in the code and ensure that it exists, in order to support gcc <11.1.0
* and gcc >=11.1.0, respectively.
*/
#if __GNUC__ > 11 || (__GNUC__ == 11 && __GNUC_MINOR__ >= 1)
static void __gcov_flush(void) {
__gcov_dump();
__gcov_reset();
}
#endif

#endif /* GCOV_WRAPPER_H */

0 comments on commit 77e9d0d

Please sign in to comment.