Parcourir la source

dpkg-buildflags: Add a bug feature to the qa feature area

This feature will enable fatal warnings for code that can pose
actual problems.

Closes: #682659
Guillem Jover il y a 12 ans
Parent
commit
1f0936a4bf
3 fichiers modifiés avec 16 ajouts et 0 suppressions
  1. 2 0
      debian/changelog
  2. 4 0
      man/dpkg-buildflags.1
  3. 10 0
      scripts/Dpkg/Vendor/Debian.pm

+ 2 - 0
debian/changelog

@@ -39,6 +39,8 @@ dpkg (1.17.14) UNRELEASED; urgency=low
   * Add support for relative symlinks to dpkg-maintscript-helper symlink_to_dir
   * Add support for relative symlinks to dpkg-maintscript-helper symlink_to_dir
     command. Suggested by Don Armstrong <don@debian.org>.
     command. Suggested by Don Armstrong <don@debian.org>.
   * Add a new dpkg-buildflags qa feature area:
   * Add a new dpkg-buildflags qa feature area:
+    - Add a new bug feature, disabled by default, which will enable fatal
+      warnings for code that can pose actual problems. Closes: #682659
 
 
   [ Raphaël Hertzog ]
   [ Raphaël Hertzog ]
   * Explain better in deb-triggers(5) why interest/activate-noawait should be
   * Explain better in deb-triggers(5) why interest/activate-noawait should be

+ 4 - 0
man/dpkg-buildflags.1

@@ -216,6 +216,10 @@ Thus disabling everything in the \fBhardening\fP area and enabling only
 .SS Quality Assurance (QA)
 .SS Quality Assurance (QA)
 Several compile-time options (detailed below) can be used to help detect
 Several compile-time options (detailed below) can be used to help detect
 problems in the source code or build system.
 problems in the source code or build system.
+.TP
+.B bug
+This setting (disabled by default) adds any warning option that reliably
+detects problematic source code. The warnings are fatal.
 .
 .
 .SS Hardening
 .SS Hardening
 Several compile-time options (detailed below) can be used to help harden
 Several compile-time options (detailed below) can be used to help harden

+ 10 - 0
scripts/Dpkg/Vendor/Debian.pm

@@ -104,11 +104,21 @@ sub _add_qa_flags {
 
 
     # Default feature states.
     # Default feature states.
     my %use_feature = (
     my %use_feature = (
+        bug => 0,
     );
     );
 
 
     # Adjust features based on Maintainer's desires.
     # Adjust features based on Maintainer's desires.
     $self->_parse_feature_area('qa', \%use_feature);
     $self->_parse_feature_area('qa', \%use_feature);
 
 
+    # Warnings that detect actual bugs.
+    if ($use_feature{bug}) {
+        foreach my $warnflag (qw(array-bounds clobbered volatile-register-var
+                                 implicit-function-declaration)) {
+            $flags->append('CFLAGS', "-Werror=$warnflag");
+            $flags->append('CXXFLAGS', "-Werror=$warnflag");
+        }
+    }
+
     # Store the feature usage.
     # Store the feature usage.
     while (my ($feature, $enabled) = each %use_feature) {
     while (my ($feature, $enabled) = each %use_feature) {
         $flags->set_feature('qa', $feature, $enabled);
         $flags->set_feature('qa', $feature, $enabled);