Re: [hackers] [surf][PATCH] Don't call setstyle with an empty path

From: Nick Hanley <nicholasjhanley_AT_gmail.com>
Date: Mon, 16 May 2022 21:22:35 -0400

On Thu, May 05, 2022 at 09:11:08AM +0200, Antonio Quartulli wrote:
> On 05/05/2022 05:38, Nick Hanley wrote:
> > On Wed, May 04, 2022 at 09:49:33AM +0200, Antonio Quartulli wrote:
> >> On 04/05/2022 00:18, Nick Hanley wrote:
> >>> On Tue, May 03, 2022 at 02:45:05PM -0400, fossy_AT_dnmx.org wrote:
> >>>> Just wondering - why not just do
> >>>> if (*getstyle(geturi(c)))
> >>>> setstyle(c, file);
> >>>
> >>> We need to pass the file path returned by getstyle to setstyle.
> >>
> >> An alternative would be to keep the original nested invocation and add a
> >> NULL check inside setstyle(). This would avoid adding an extra variable
> >> 'file'.
> >
> > Is there a reason to avoid declaring a variable?
>
> Well, the variable was not there, so the question is: is there a reason
> to add it? :-D
> IMHO the code is easier without it (as the variable is not used anywhere
> else)

I think checking that getstyle returned a valid path is clearer than
putting a NULL check in setstyle. It's the caller's responsibility to
pass valid arguments, and there's no reason to call setstyle with NULL
otherwise.

P.S. Apologies for the delay. Mail server gremlins ate my reply.
Received on Tue May 17 2022 - 03:22:35 CEST

This archive was generated by hypermail 2.3.0 : Tue May 17 2022 - 06:24:29 CEST