Skip to content

Commit 0f53474

Browse files
committed
Disable use of C23 attributes when using PVS Studio
PVS Studio does not support C23 attributes.
1 parent cf3f0fa commit 0f53474

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

config.h.in

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,9 @@
743743
/* Define to 1 if you have the <pty.h> header file. */
744744
#undef HAVE_PTY_H
745745

746+
/* Define to 1 if you are using PVS Studio to scan sudo. */
747+
#undef HAVE_PVS_STUDIO
748+
746749
/* Define to 1 if you have the 'pwrite' function. */
747750
#undef HAVE_PWRITE
748751

@@ -1582,7 +1585,7 @@ typedef unsigned int socklen_t;
15821585
#endif
15831586

15841587
/* For functions that call exit() directly. */
1585-
#ifdef __has_c_attribute
1588+
#if defined(__has_c_attribute) && !defined(HAVE_PVS_STUDIO)
15861589
# if __has_c_attribute(__noreturn__)
15871590
# define sudo_noreturn [[__noreturn__]]
15881591
# endif
@@ -1621,7 +1624,7 @@ typedef unsigned int socklen_t;
16211624
#endif
16221625

16231626
/* C23 defines a fallthrough attribute, gcc 7.0 and clang 10 have their own. */
1624-
#ifdef __has_c_attribute
1627+
#if defined(__has_c_attribute) && !defined(HAVE_PVS_STUDIO)
16251628
# if __has_c_attribute(__fallthrough__)
16261629
# define FALLTHROUGH [[__fallthrough__]]
16271630
# endif

configure

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8955,6 +8955,9 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
89558955

89568956

89578957
if test X"$enable_pvs_studio" = X"yes"; then
8958+
printf "%s\n" "#define HAVE_PVS_STUDIO 1" >>confdefs.h
8959+
8960+
89588961
# Determine preprocessor type
89598962
case "$CC" in
89608963
*clang*) preprocessor=clang;;
@@ -40104,5 +40107,6 @@ fi
4010440107

4010540108

4010640109

40110+
4010740111

4010840112

configure.ac

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4794,6 +4794,7 @@ AH_TEMPLATE(SUDOERS_LOG_CLIENT, [Define to 1 to compile support for sudo_logsrvd
47944794
AH_TEMPLATE(HAVE_FALLTHROUGH_ATTRIBUTE, [Define to 1 if the compiler supports the fallthrough attribute.])
47954795
AH_TEMPLATE(HAVE_VA_COPY, [Define to 1 if you have the 'va_copy' function.])
47964796
AH_TEMPLATE(HAVE___VA_COPY, [Define to 1 if you have the '__va_copy' function.])
4797+
AH_TEMPLATE(HAVE_PVS_STUDIO, [Define to 1 if you are using PVS Studio to scan sudo.])
47974798

47984799
dnl
47994800
dnl Bits to copy verbatim into config.h.in
@@ -4827,7 +4828,7 @@ typedef unsigned int socklen_t;
48274828
#endif
48284829
48294830
/* For functions that call exit() directly. */
4830-
#ifdef __has_c_attribute
4831+
#if defined(__has_c_attribute) && !defined(HAVE_PVS_STUDIO)
48314832
# if __has_c_attribute(__noreturn__)
48324833
# define sudo_noreturn [[__noreturn__]]
48334834
# endif
@@ -4866,7 +4867,7 @@ typedef unsigned int socklen_t;
48664867
#endif
48674868
48684869
/* C23 defines a fallthrough attribute, gcc 7.0 and clang 10 have their own. */
4869-
#ifdef __has_c_attribute
4870+
#if defined(__has_c_attribute) && !defined(HAVE_PVS_STUDIO)
48704871
# if __has_c_attribute(__fallthrough__)
48714872
# define FALLTHROUGH [[__fallthrough__]]
48724873
# endif

m4/sudo.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,8 @@ dnl Create PVS-Studio.cfg for supported platforms or throw an error.
595595
dnl
596596
AC_DEFUN([SUDO_PVS_STUDIO_CFG], [
597597
if test X"$enable_pvs_studio" = X"yes"; then
598+
AC_DEFINE(HAVE_PVS_STUDIO)
599+
598600
# Determine preprocessor type
599601
case "$CC" in
600602
*clang*) preprocessor=clang;;

0 commit comments

Comments
 (0)