Web lists-archives.com

Re: [PATCH v4 02/11] Add initial support for many promisor remotes




On Thu, Apr 4, 2019 at 12:08 AM SZEDER Gábor <szeder.dev@xxxxxxxxx> wrote:
>
> On Mon, Apr 01, 2019 at 06:40:36PM +0200, Christian Couder wrote:
> > diff --git a/promisor-remote.c b/promisor-remote.c
> > new file mode 100644
> > index 0000000000..0c768210ee
> > --- /dev/null
> > +++ b/promisor-remote.c
> > @@ -0,0 +1,92 @@
> > +#include "cache.h"
> > +#include "promisor-remote.h"
> > +#include "config.h"
> > +
> > +static struct promisor_remote *promisors;
> > +static struct promisor_remote **promisors_tail = &promisors;
> > +
> > +static struct promisor_remote *promisor_remote_new(const char *remote_name)
> > +{
> > +     struct promisor_remote *r;
> > +
> > +     if (*remote_name == '/') {
> > +             warning(_("promisor remote name cannot begin with '/': %s"),
> > +                     remote_name);
> > +             return NULL;
> > +     }
> > +
> > +     FLEX_ALLOC_STR(r, name, remote_name);
> > +
> > +     *promisors_tail = r;
> > +     promisors_tail = &r->next;
> > +
> > +     return r;
> > +}
> > +
> > +static struct promisor_remote *promisor_remote_lookup(const char *remote_name,
> > +                                                   struct promisor_remote **previous)
> > +{
> > +     struct promisor_remote *r, *p;
> > +
> > +     for (p = NULL, r = promisors; r; p = r, r = r->next)
> > +             if (r->name && !strcmp(r->name, remote_name)) {
>
> r->name is a FLEX_ARRAY, and Clang complains about this condition:
>
>   promisor-remote.c:34:10: error: address of array 'r->name' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
>                   if (r->name && !strcmp(r->name, remote_name)) {
>                       ~~~^~~~ ~~
>   1 error generated.
>   make: *** [promisor-remote.o] Error 1

Yeah, it's a left over from the previous version where it wasn't a FLEX_ARRAY.

Thanks!