[apparmor] [patch] parser: fix warning in net_find_af_name
John Johansen
john.johansen at canonical.com
Thu Mar 19 07:04:38 UTC 2015
On 03/18/2015 11:22 PM, Steve Beattie wrote:
> 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.
Acked-by: John Johansen <john.johansen at canonical.com>
> ---
> 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;
>
>
>
More information about the AppArmor
mailing list