[apparmor] Rev 2456: Unify escape sequence processing into a set of library fns.

John Johansen john.johansen at canonical.com
Thu Apr 17 06:18:44 UTC 2014


On 04/16/2014 11:08 PM, Steve Beattie wrote:
> Unfortunately, this patch breaks builds on i386, with the following
> failure:
> 
>   g++ -g -O2 -pipe -Wall -Wsign-compare -Wmissing-field-initializers -Wformat-security -Wunused-parameter -std=gnu++0x -D_GNU_SOURCE -DPACKAGE=\"apparmor-parser\" -DLOCALEDIR=\"/usr/share/locale\" -DSUBDOMAIN_CONFDIR=\"/etc/apparmor\" -I../libraries/libapparmor//include -c -o lib.o lib.c
>   lib.c: In function 'int strn_escseq(const char**, const char*, size_t)':
>   lib.c:236:47: error: no matching function for call to 'min(long unsigned int, size_t&)'
>      tmp = strntol(*pos, &end, 8, 255, min(3ul, n));
>                                                 ^
> 
> This is due to size_t differing in size on i386 and amd64. The
> following patch addresses the issue by casting the constant values to
> size_t, satisfying C++'s types (and the patch removes the unnecessary
> min macro).
> 
> Signed-off-by: Steve Beattie <steve at nxnw.org>

Acked-by: John Johansen <john.johansen at canonical.com>

though you might want to consider dropping the ul suffix since we are casting anyways

> 
> === modified file 'parser/lib.c'
> --- parser/lib.c	2014-04-15 21:59:41 +0000
> +++ parser/lib.c	2014-04-17 05:40:18 +0000
> @@ -233,7 +233,7 @@
>  		return -1;
>  
>  	if (isodigit(**pos)) {
> -		tmp = strntol(*pos, &end, 8, 255, min(3ul, n));
> +		tmp = strntol(*pos, &end, 8, 255, min((size_t) 3ul, n));
>  		if (tmp == 0 && end == *pos) {
>  			/* this should never happen because of isodigit test */
>  			return -1;
> @@ -249,7 +249,7 @@
>  	case '"':
>  		return '"';
>  	case 'd':
> -		tmp = strntol(*pos, &end, 10, 255, min(3ul, n));
> +		tmp = strntol(*pos, &end, 10, 255, min((size_t) 3ul, n));
>  		if (tmp == 0 && end == *pos) {
>  			/* \d no valid encoding */
>  			return -1;
> @@ -257,7 +257,7 @@
>  		*pos = end;
>  		return tmp;
>  	case 'x':
> -		tmp = strntol(*pos, &end, 16, 255, min(2ul, n));
> +		tmp = strntol(*pos, &end, 16, 255, min((size_t) 2ul, n));
>  		if (tmp == 0 && end == *pos) {
>  			/* \x no valid encoding */
>  			return -1;
> 
> === modified file 'parser/lib.h'
> --- parser/lib.h	2014-04-15 21:59:41 +0000
> +++ parser/lib.h	2014-04-17 05:41:28 +0000
> @@ -3,11 +3,6 @@
>  
>  #include <dirent.h>
>  
> -#define min(a,b) \
> -   ({ __typeof__ (a) _a = (a); \
> -       __typeof__ (b) _b = (b); \
> -     _a < _b ? _a : _b; })
> -
>  int dirat_for_each(DIR *dir, const char *name, void *data,
>  		   int (* cb)(DIR *, const char *, struct stat *, void *));
>  
> 
> 
> 




More information about the AppArmor mailing list