summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2019-02-20 11:32:33 +0100
committerGuillem Jover <guillem@debian.org>2019-02-23 15:25:01 +0100
commit6d43bd729668c801f1fa3402b4d95fe4b0caf2c0 (patch)
tree709ae7f289be839b91ccf259a9372a7a9812d6b3
parentbe0504ce8b38a653c43a33ce6b4b70722e2e46a5 (diff)
downloaddpkg-6d43bd729668c801f1fa3402b4d95fe4b0caf2c0.tar.gz
dpkg: Simplify maintscript_set_exec_context()
We do not really need to normalize the return code, which was confusing the cppcheck for which we required a supression.
-rw-r--r--debian/changelog1
-rw-r--r--src/script.c7
-rw-r--r--t/cppcheck/cppcheck.supp4
3 files changed, 4 insertions, 8 deletions
diff --git a/debian/changelog b/debian/changelog
index 7cdd3bbe4..c31d1fb23 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,7 @@ dpkg (1.19.5) UNRELEASED; urgency=medium
Closes: #921557
* Code internals:
- dpkg: Move SELinux fallback label to the SELinux specific code path.
+ - dpkg: Simplify maintscript_set_exec_context().
* Build system:
- Check whether this dist is a release, based only on the version format.
This will avoid having to do a two staged release to get a proper perl
diff --git a/src/script.c b/src/script.c
index f02ca509e..ea63093af 100644
--- a/src/script.c
+++ b/src/script.c
@@ -160,13 +160,12 @@ maintscript_pre_exec(struct command *cmd)
static int
maintscript_set_exec_context(struct command *cmd)
{
- int rc = 0;
-
#ifdef WITH_LIBSELINUX
- rc = setexecfilecon(cmd->filename, "dpkg_script_t");
+ return setexecfilecon(cmd->filename, "dpkg_script_t");
+#else
+ return 0;
#endif
- return rc < 0 ? rc : 0;
}
static int
diff --git a/t/cppcheck/cppcheck.supp b/t/cppcheck/cppcheck.supp
index 83f1821cb..6dcb19361 100644
--- a/t/cppcheck/cppcheck.supp
+++ b/t/cppcheck/cppcheck.supp
@@ -12,10 +12,6 @@ variableScope
unusedStructMember:lib/compat/obstack.c
nullPointerArithmetic:lib/compat/obstack.c
-// Ignore, we use this construct to ease portability.
-knownConditionTrueFalse:src/script.c:169
-duplicateExpressionTernary:src/script.c:169
-
// Ignore, we are testing the functions.
knownConditionTrueFalse:lib/dpkg/t/t-macros.c