Skip to contentSkip to conversation

libselinux: fix unused variable error

PATCH Applied [email protected] 3 participants 3 messages Sep 28, 2016 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux: fix unused variable error

From: William Roberts <[email protected]>

When building for Android, this error manifests itself:

label_file.c:570:7: error: unused variable ‘subs_file’ [-Werror=unused-variable]
char subs_file[PATH_MAX + 1];

Fix it by moving the variable into the ifdef'd usage block.

---
 libselinux/src/label_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/label_file.c +1 -1
index adf3dcc..a4dc3cd 100644
@@ -567,7 +567,6 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
 	struct saved_data *data = (struct saved_data *)rec->data;
 	const char *path = NULL;
 	const char *prefix = NULL;
-	char subs_file[PATH_MAX + 1];
 	int status = -1, baseonly = 0;
 
 	/* Process arguments */
@@ -585,6 +584,7 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
 		}
 
 #if !defined(BUILD_HOST) && !defined(ANDROID)
+	char subs_file[PATH_MAX + 1];
 	/* Process local and distribution substitution files */
 	if (!path) {
 		rec->dist_subs =
Signature · 1 line
1.9.1
#1 lore raw
Quoted 7 lines · On Wed, Sep 28, 2016 at 11:53 AM, <[email protected]> wrote:

From: William Roberts <[email protected]>

When building for Android, this error manifests itself:

label_file.c:570:7: error: unused variable ‘subs_file’ [-Werror=unused-variable]
char subs_file[PATH_MAX + 1];

FYI this just happened when building with ANDROID_HOST=y on my development branch, so I am
assuming some Makefile change introduced a hard error on it... inside the android tree, it was still
building, without even printing a warning as well.

Quoted 35 lines

Fix it by moving the variable into the ifdef'd usage block.

---
 libselinux/src/label_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/label_file.c +1 -2
index adf3dcc..a4dc3cd 100644
@@ -567,7 +567,6 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
        struct saved_data *data = (struct saved_data *)rec->data;
        const char *path = NULL;
        const char *prefix = NULL;
-       char subs_file[PATH_MAX + 1];
        int status = -1, baseonly = 0;
 
        /* Process arguments */
@@ -585,6 +584,7 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
                }
 
 #if !defined(BUILD_HOST) && !defined(ANDROID)
+       char subs_file[PATH_MAX + 1];
        /* Process local and distribution substitution files */
        if (!path) {
                rec->dist_subs =
--

1.9.1

_______________________________________________
Seandroid-list mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

#2 lore raw
In reply to [email protected]
Quoted 8 lines · On 09/28/2016 11:53 AM, [email protected] wrote:

From: William Roberts <[email protected]>

When building for Android, this error manifests itself:

label_file.c:570:7: error: unused variable ‘subs_file’ [-Werror=unused-variable]
char subs_file[PATH_MAX + 1];

Fix it by moving the variable into the ifdef'd usage block.

Thanks, applied.

Quoted 27 lines
---
 libselinux/src/label_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/label_file.c +1 -1
index adf3dcc..a4dc3cd 100644
@@ -567,7 +567,6 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
 	struct saved_data *data = (struct saved_data *)rec->data;
 	const char *path = NULL;
 	const char *prefix = NULL;
-	char subs_file[PATH_MAX + 1];
 	int status = -1, baseonly = 0;
 
 	/* Process arguments */
@@ -585,6 +584,7 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
 		}
 
 #if !defined(BUILD_HOST) && !defined(ANDROID)
+	char subs_file[PATH_MAX + 1];
 	/* Process local and distribution substitution files */
 	if (!path) {
 		rec->dist_subs =