[apparmor] [patch] parser: fix warning in net_find_af_name

Steve Beattie steve at nxnw.org
Thu Mar 19 06:22:57 UTC 2015


Hello,

The fix to prevent the compiler from SEGV'ing when dumping network
rules in commit 2888 introduced the following compiler warning:

  network.c: In function ‘const char* net_find_af_name(unsigned int)’:
  network.c:331:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (i = 0; i < sizeof(network_mappings) / sizeof(*network_mappings); i++) {

The problem is that the counter i is an int, but sizeof returns size_t
which is unsigned. The following patch fixes the issue by converting the
type of i to size_t.

Signed-off-by: Steve Beattie <steve at nxnw.org> for trunk and 2.9.
---
 parser/network.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: b/parser/network.c
===================================================================
--- a/parser/network.c
+++ b/parser/network.c
@@ -323,7 +323,7 @@ struct aa_network_entry *network_entry(c
 
 const char *net_find_af_name(unsigned int af)
 {
-	int i;
+	size_t i;
 
 	if (af < 0 || af > get_af_max())
 		return NULL;

-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150318/7a7552e8/attachment.pgp>


More information about the AppArmor mailing list