Re: [PATCH v2 1/7] path.c: implement xdg_config_home()
- From
Paul Tan <pyokagan@gmail.com>
- Date
- Apr 18, 2015, 08:48 UTC
- Message-ID
- <CACRoPnRMHDO3VC1-S2rpx7jgcv=c_ym6wRSx2xxNRk=k_vtXvA@mail.gmail.com>
- In-Reply-To
- <CAPig+cTrErOBwPteeA1d_gdve5SiyLnbyFPpQ1sTN7aajGJfeA@mail.gmail.com>
Hi,
On Fri, Apr 17, 2015 at 5:41 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 10 quoted lines
> On Tue, Apr 14, 2015 at 1:28 PM, Paul Tan <pyokagan@gmail.com> wrote: >> Below is the fixed patch. I also decided to return NULL if `filename` is >> NULL because such an input usually indicated an uncaught error. > > Unfortunately, this blurs the line between programmer error (passing > NULL for filename) and a user/configuration error (XDG_CONFIG_HOME and > HOME being undefined). If there is indeed no valid interpretation for > filename==NULL, then it may be better to die() or assert() here to > flag the programmer error as early as possible, rather than returning > NULL.
I'm inclined to agree, but off the top of my head an API user may wish to do:
xdg_config_home(function_which_returns_NULL_on_error())
And wish for the error to propagate, but that may be considered sloppy programming and so it's better to treat a NULL input as a bug.
Will fix this by calling assert(). Thanks.
Regards, Paul