]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Henrik Nordstrom <henrik@henriknordstrom.net>
authorAmos Jeffries <amosjeffries@squid-cache.org>
Mon, 2 Jun 2008 11:07:57 +0000 (05:07 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Mon, 2 Jun 2008 11:07:57 +0000 (05:07 -0600)
Simplify linux capabilities version check to avoid repeated #ifdefs cluttering the code

src/tools.cc

index d1cb7e4529f381b871c62750b7e33e0bd3028820..ee6eafad1cbf28a583be835f999f3051e22d3d7c 100644 (file)
@@ -1357,27 +1357,21 @@ static void
 restoreCapabilities(int keep)
 {
 #if defined(_SQUID_LINUX_) && HAVE_SYS_CAPABILITY_H
+#ifndef _LINUX_CAPABILITY_VERSION_1
+#define _LINUX_CAPABILITY_VERSION_1 _LINUX_CAPABILITY_VERSION
+#endif
     cap_user_header_t head = (cap_user_header_t) xcalloc(1, sizeof(*head));
     cap_user_data_t cap = (cap_user_data_t) xcalloc(1, sizeof(*cap));
 
-#ifdef  _LINUX_CAPABILITY_VERSION_1
     head->version = _LINUX_CAPABILITY_VERSION_1;
-#else
-    head->version = _LINUX_CAPABILITY_VERSION;
-#endif
 
     if (capget(head, cap) != 0) {
         debugs(50, 1, "Can't get current capabilities");
         goto nocap;
     }
 
-#ifdef  _LINUX_CAPABILITY_VERSION_1
     if (head->version != _LINUX_CAPABILITY_VERSION_1) {
         debugs(50, 1, "Invalid capability version " << head->version << " (expected " << _LINUX_CAPABILITY_VERSION_1 << ")");
-#else
-    if (head->version != _LINUX_CAPABILITY_VERSION) {
-        debugs(50, 1, "Invalid capability version " << head->version << " (expected " << _LINUX_CAPABILITY_VERSION << ")");
-#endif
         goto nocap;
     }