Re: RFC: warnings on ignoring return value on some list operations



On Thu, 2005-11-24 at 15:50 +0100, Tim Janik wrote:
> On Thu, 24 Nov 2005, Owen Taylor wrote:
> 
> > On Thu, 2005-11-24 at 11:58 +0100, Tim Janik wrote:
> >
> >> i think that is a really good idea. however i'm more of the opinion that all
> >> list functions should have the warn_unused_result tag. code and conditions
> >> are easily changed, moved around or pasted so that missing the return value
> >> assignment for lists will become a problem. i.e. even if you know you're
> >> appending to a non-empty list, you should still write
> >> list = g_list_append (list, data);
> >>
> >> so i'd apprchiate if you extended the patch to cover all list functions
> >> that return possibly modified lists ;)
> >
> > What happened to compatibility?
> 
> could you please outline how you see compatibility affected by this?

 if (head) {
    g_list_append(tail, new);
    tail = tail->next;
 } else {
    head = tail = g_list_append(null, new);
 }

strikes me as acceptable code, and I know there are some examples like this
in GTK+. Maybe the gain is worth the pain ... unless someone is compiling
production code with -Werror it isn't going to *break* a build, and there
is no bin-compat issue. But it's definitely a compatibility break of some
sort.

Does 

   (void)g_list_append(tail, new);

Suppress the warning?

Regards,
							Owen

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]