summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-06-01 14:35:59 +0200
committerThomas Haller <thaller@redhat.com>2015-06-02 12:57:52 +0200
commit8be9e832b59d5fb4cece9b76d7e6bdf43d1f5445 (patch)
tree320e0890cc2824c116f31a8fbc745e62e349e663
parent4ef8c0c90ce213303505e2eab3db4f8741ad6d94 (diff)
downloadNetworkManager-8be9e832b59d5fb4cece9b76d7e6bdf43d1f5445.tar.gz
ifcfg-rh: refactor utils_should_ignore_file() to return early
-rw-r--r--src/settings/plugins/ifcfg-rh/utils.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/src/settings/plugins/ifcfg-rh/utils.c b/src/settings/plugins/ifcfg-rh/utils.c
index 87f4aba3e5..5519aac716 100644
--- a/src/settings/plugins/ifcfg-rh/utils.c
+++ b/src/settings/plugins/ifcfg-rh/utils.c
@@ -27,6 +27,7 @@
#include "nm-core-internal.h"
#include "nm-macros-internal.h"
#include "NetworkManagerUtils.h"
+#include "gsystem-local-alloc.h"
#include "utils.h"
#include "shvar.h"
@@ -151,41 +152,34 @@ check_suffix (const char *base, const char *tag)
gboolean
utils_should_ignore_file (const char *filename, gboolean only_ifcfg)
{
- char *base;
- gboolean ignore = TRUE;
- gboolean is_ifcfg = FALSE;
- gboolean is_other = FALSE;
+ gs_free char *base = NULL;
g_return_val_if_fail (filename != NULL, TRUE);
base = g_path_get_basename (filename);
- g_return_val_if_fail (base != NULL, TRUE);
/* Only handle ifcfg, keys, and routes files */
- if (!strncmp (base, IFCFG_TAG, strlen (IFCFG_TAG)))
- is_ifcfg = TRUE;
-
- if (only_ifcfg == FALSE) {
- if ( !strncmp (base, KEYS_TAG, strlen (KEYS_TAG))
- || !strncmp (base, ROUTE_TAG, strlen (ROUTE_TAG))
- || !strncmp (base, ROUTE6_TAG, strlen (ROUTE6_TAG)))
- is_other = TRUE;
+ if (strncmp (base, IFCFG_TAG, strlen (IFCFG_TAG)) != 0) {
+ if (only_ifcfg)
+ return TRUE;
+ else if ( strncmp (base, KEYS_TAG, strlen (KEYS_TAG)) != 0
+ && strncmp (base, ROUTE_TAG, strlen (ROUTE_TAG)) != 0
+ && strncmp (base, ROUTE6_TAG, strlen (ROUTE6_TAG)) != 0)
+ return TRUE;
}
/* But not those that have certain suffixes */
- if ( (is_ifcfg || is_other)
- && !check_suffix (base, BAK_TAG)
- && !check_suffix (base, TILDE_TAG)
- && !check_suffix (base, ORIG_TAG)
- && !check_suffix (base, REJ_TAG)
- && !check_suffix (base, RPMNEW_TAG)
- && !check_suffix (base, AUGNEW_TAG)
- && !check_suffix (base, AUGTMP_TAG)
- && !check_rpm_temp_suffix (base))
- ignore = FALSE;
+ if ( check_suffix (base, BAK_TAG)
+ || check_suffix (base, TILDE_TAG)
+ || check_suffix (base, ORIG_TAG)
+ || check_suffix (base, REJ_TAG)
+ || check_suffix (base, RPMNEW_TAG)
+ || check_suffix (base, AUGNEW_TAG)
+ || check_suffix (base, AUGTMP_TAG)
+ || check_rpm_temp_suffix (base))
+ return TRUE;
- g_free (base);
- return ignore;
+ return FALSE;
}
char *