Skip to contentSkip to conversation

apparmorfs: Fine-tuning for three function implementations

PATCH In review SF Markus Elfring 2 participants 5 messages May 7, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover apparmorfs: Fine-tuning for three function implementations

From: Markus Elfring <[email protected]>
Date: Sun, 7 May 2017 13:58:08 +0200

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Combine two function calls into one in aa_fs_seq_raw_abi_show() Use seq_putc() in two functions

 security/apparmor/apparmorfs.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
Signature · 1 line
2.12.2
#1 lore raw

PATCH 1/2 apparmorfs: Combine two function calls into one in aa_fs_seq_raw_abi_show()

From: Markus Elfring <[email protected]>
Date: Sun, 7 May 2017 13:43:50 +0200

A bit of data was put into a sequence by two separate function calls. Print the same data by a single function call instead.

---
 security/apparmor/apparmorfs.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
security/apparmor/apparmorfs.c +3 -4
index 4f6ac9dbc65d..b4d83e0bc651 100644
@@ -572,10 +572,9 @@ static int aa_fs_seq_raw_abi_show(struct seq_file *seq, void *v)
 	struct aa_proxy *proxy = seq->private;
 	struct aa_profile *profile = aa_get_profile_rcu(&proxy->profile);
 
-	if (profile->rawdata->abi) {
-		seq_printf(seq, "v%d", profile->rawdata->abi);
-		seq_puts(seq, "\n");
-	}
+	if (profile->rawdata->abi)
+		seq_printf(seq, "v%d\n", profile->rawdata->abi);
+
 	aa_put_profile(profile);
 
 	return 0;
Signature · 1 line
2.12.2
#3 lore raw

PATCH 2/2 apparmorfs: Use seq_putc() in two functions

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 7 May 2017 13:50:28 +0200

Two single characters (line breaks) should be put into a sequence. Thus use the corresponding function "seq_putc".

This issue was detected by using the Coccinelle software.

---
 security/apparmor/apparmorfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/apparmor/apparmorfs.c +2 -2
index b4d83e0bc651..41e427a4f051 100644
@@ -494,7 +494,7 @@ static int aa_fs_seq_hash_show(struct seq_file *seq, void *v)
 	if (profile->hash) {
 		for (i = 0; i < size; i++)
 			seq_printf(seq, "%.2x", profile->hash[i]);
-		seq_puts(seq, "\n");
+		seq_putc(seq, '\n');
 	}
 	aa_put_profile(profile);
 
@@ -602,7 +602,7 @@ static int aa_fs_seq_raw_hash_show(struct seq_file *seq, void *v)
 	if (profile->rawdata->hash) {
 		for (i = 0; i < size; i++)
 			seq_printf(seq, "%.2x", profile->rawdata->hash[i]);
-		seq_puts(seq, "\n");
+		seq_putc(seq, '\n');
 	}
 	aa_put_profile(profile);
 
Signature · 1 line
2.12.2
maintainer Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] apparmorfs: Combine two function calls into one in aa_fs_seq_raw_abi_show()

In reply to SF Markus Elfring
Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 7 May 2017 13:43:50 +0200

A bit of data was put into a sequence by two separate function calls. Print the same data by a single function call instead.

I'll pull it into my tree for my next push

Quoted 23 lines
---
 security/apparmor/apparmorfs.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
security/apparmor/apparmorfs.c +3 -4
index 4f6ac9dbc65d..b4d83e0bc651 100644
@@ -572,10 +572,9 @@ static int aa_fs_seq_raw_abi_show(struct seq_file *seq, void *v)
 	struct aa_proxy *proxy = seq->private;
 	struct aa_profile *profile = aa_get_profile_rcu(&proxy->profile);
 
-	if (profile->rawdata->abi) {
-		seq_printf(seq, "v%d", profile->rawdata->abi);
-		seq_puts(seq, "\n");
-	}
+	if (profile->rawdata->abi)
+		seq_printf(seq, "v%d\n", profile->rawdata->abi);
+
 	aa_put_profile(profile);
 
 	return 0;
maintainer Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] apparmorfs: Use seq_putc() in two functions

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 7 May 2017 13:50:28 +0200

Two single characters (line breaks) should be put into a sequence. Thus use the corresponding function "seq_putc".

This issue was detected by using the Coccinelle software.

I'll pull it into my tree for my next push

Quoted 27 lines
---
 security/apparmor/apparmorfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/apparmor/apparmorfs.c +2 -2
index b4d83e0bc651..41e427a4f051 100644
@@ -494,7 +494,7 @@ static int aa_fs_seq_hash_show(struct seq_file *seq, void *v)
 	if (profile->hash) {
 		for (i = 0; i < size; i++)
 			seq_printf(seq, "%.2x", profile->hash[i]);
-		seq_puts(seq, "\n");
+		seq_putc(seq, '\n');
 	}
 	aa_put_profile(profile);
 
@@ -602,7 +602,7 @@ static int aa_fs_seq_raw_hash_show(struct seq_file *seq, void *v)
 	if (profile->rawdata->hash) {
 		for (i = 0; i < size; i++)
 			seq_printf(seq, "%.2x", profile->rawdata->hash[i]);
-		seq_puts(seq, "\n");
+		seq_putc(seq, '\n');
 	}
 	aa_put_profile(profile);