authselect/SOURCES/0032-util-do-not-return-val...

151 lines
4.7 KiB
Diff

From 67b5d7778cad682bf8046973900caf2fa3353d0e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Wed, 28 Nov 2018 13:59:51 +0100
Subject: [PATCH 14/15] util: do not return value from string_array_del_value
It is not needed.
---
src/lib/authselect.c | 9 ++-------
src/lib/util/string_array.c | 6 +++---
src/lib/util/string_array.h | 2 +-
src/tests/test_util_string_array.c | 28 ++++++++--------------------
4 files changed, 14 insertions(+), 31 deletions(-)
diff --git a/src/lib/authselect.c b/src/lib/authselect.c
index e0b8b1246b0e7139494d90cca4e0ebed3eb66376..0f8d4a8b6d0b0faef81daf176486108ed0ea74db 100644
--- a/src/lib/authselect.c
+++ b/src/lib/authselect.c
@@ -179,7 +179,7 @@ authselect_apply_changes(void)
WARN("Profile feature [%s] is no longer supported, removing it...",
features[i]);
- features = string_array_del_value(features, features[i]);
+ string_array_del_value(features, features[i]);
i--;
}
@@ -247,15 +247,10 @@ authselect_feature_disable(const char *feature)
return ret;
}
- features = string_array_del_value(features, feature);
- if (features == NULL) {
- ret = ENOMEM;
- goto done;
- }
+ string_array_del_value(features, feature);
ret = authselect_activate(profile_id, (const char **)features, false);
-done:
string_array_free(features);
free(profile_id);
diff --git a/src/lib/util/string_array.c b/src/lib/util/string_array.c
index a8afa5ab8edbb26d6f946619f9ce0b83c511bb8c..e8871dc067fbf3d461d1ee9579813ddc81eef676 100644
--- a/src/lib/util/string_array.c
+++ b/src/lib/util/string_array.c
@@ -137,7 +137,7 @@ string_array_add_value(char **array, const char *value, bool unique)
return string_array_add_value_safe(array, value, strlen(value), unique);
}
-char **
+void
string_array_del_value(char **array, const char *value)
{
size_t count;
@@ -145,7 +145,7 @@ string_array_del_value(char **array, const char *value)
size_t i;
if (array == NULL) {
- return NULL;
+ return;
}
count = string_array_count(array);
@@ -167,7 +167,7 @@ string_array_del_value(char **array, const char *value)
array[pos] = NULL;
}
- return array;
+ return;
}
char **
diff --git a/src/lib/util/string_array.h b/src/lib/util/string_array.h
index ba9760b5d66a9619ca8edea5e3418c5cfbbec929..5842db174563982528e20354138ef5792346fb37 100644
--- a/src/lib/util/string_array.h
+++ b/src/lib/util/string_array.h
@@ -115,7 +115,7 @@ string_array_add_value(char **array, const char *value, bool unique);
*
* @return Array without the value.
*/
-char **
+void
string_array_del_value(char **array, const char *value);
/**
diff --git a/src/tests/test_util_string_array.c b/src/tests/test_util_string_array.c
index 249cb96acea3c4feac910702572cafb1025d9496..ad76f8b190b823210b5e30ae828dce6518596e3b 100644
--- a/src/tests/test_util_string_array.c
+++ b/src/tests/test_util_string_array.c
@@ -51,8 +51,7 @@ void test_string_array_del_value__single(void **state)
assert_null(array[i]);
/* Delete value. */
- array = string_array_del_value(array, "2");
- assert_non_null(array);
+ string_array_del_value(array, "2");
/* Test values. */
for (i = 0; expected[i] != NULL; i++) {
@@ -83,8 +82,7 @@ void test_string_array_del_value__single_repeated(void **state)
assert_null(array[i]);
/* Delete value. */
- array = string_array_del_value(array, "2");
- assert_non_null(array);
+ string_array_del_value(array, "2");
/* Test values. */
for (i = 0; expected[i] != NULL; i++) {
@@ -115,14 +113,9 @@ void test_string_array_del_value__multiple(void **state)
assert_null(array[i]);
/* Delete value. */
- array = string_array_del_value(array, "2");
- assert_non_null(array);
-
- array = string_array_del_value(array, "3");
- assert_non_null(array);
-
- array = string_array_del_value(array, "5");
- assert_non_null(array);
+ string_array_del_value(array, "2");
+ string_array_del_value(array, "3");
+ string_array_del_value(array, "5");
/* Test values. */
for (i = 0; expected[i] != NULL; i++) {
@@ -153,14 +146,9 @@ void test_string_array_del_value__multiple_repeated(void **state)
assert_null(array[i]);
/* Delete value. */
- array = string_array_del_value(array, "2");
- assert_non_null(array);
-
- array = string_array_del_value(array, "3");
- assert_non_null(array);
-
- array = string_array_del_value(array, "5");
- assert_non_null(array);
+ string_array_del_value(array, "2");
+ string_array_del_value(array, "3");
+ string_array_del_value(array, "5");
/* Test values. */
for (i = 0; expected[i] != NULL; i++) {
--
2.17.2