On Tue, Jan 03, 2012 at 11:50:32AM -0800, John Johansen wrote: > On 01/03/2012 11:17 AM, Steve Beattie wrote: > >I suspect the reason the rc variable got added was to avoid the unused > >result warning on the asprintf call that results: > > > > parser_common.c: In function ‘pwarn’: > > parser_common.c:61:17: warning: ignoring return value of ‘asprintf’, > > declared with attribute warn_unused_result [-Wunused-result] > > > > err yes, sorry the patch for that seems to have not been included, see below > > --- > > From 4fd7804333d4a6386858bfd6d75aaed94aa9d6f2 Mon Sep 17 00:00:00 2001 > From: John Johansen <[email protected]> > Date: Tue, 3 Jan 2012 11:43:21 -0800 > Subject: [PATCH] Remove asprintf warning and fix invalid test > > asprintf is marked with warn_unused_result and its return value should > not be ignored, even casting to (void) will not remove this warning. > > The current code ignored the result and used the value of newfmt to > make a decision. This is however not correct in that according to the > asprintf man page newfmt is undefined if asprintf returns an error. > > Fix the warning and error by using the return value of asprintf > > Signed-off-by: John Johansen <[email protected]>
Acked-By: Steve Beattie <[email protected]> Thanks! > --- > parser/parser_common.c | 13 ++++++------- > 1 files changed, 6 insertions(+), 7 deletions(-) > > diff --git a/parser/parser_common.c b/parser/parser_common.c > index 59df46c..df78a10 100644 > --- a/parser/parser_common.c > +++ b/parser/parser_common.c > @@ -58,13 +58,12 @@ void pwarn(char *fmt, ...) > if (conf_quiet || names_only || option == OPTION_REMOVE) > return; > - asprintf(&newfmt, _("Warning from %s (%s%sline %d): %s"), > - profilename ? profilename : "stdin", > - current_filename ? current_filename : "", > - current_filename ? " " : "", > - current_lineno, > - fmt); > - if (!newfmt) > + if (asprintf(&newfmt, _("Warning from %s (%s%sline %d): %s"), > + profilename ? profilename : "stdin", > + current_filename ? current_filename : "", > + current_filename ? " " : "", > + current_lineno, > + fmt) == -1) > return; > va_start(arg, fmt); > -- > 1.7.7.3 -- Steve Beattie <[email protected]> http://NxNW.org/~steve/
signature.asc
Description: Digital signature
-- AppArmor mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
