Re: [PATCH 1/6] lib/cli: Make notmuch_database_open return a status code

Subject: Re: [PATCH 1/6] lib/cli: Make notmuch_database_open return a status code

Date: Mon, 30 Apr 2012 12:15:55 -0400

To: David Bremner

Cc: notmuch@notmuchmail.org

From: Austin Clements


Quoth David Bremner on Apr 30 at  8:39 am:
> 
> I have two questions, both of which might have been settled previously.
> 
> >  
> > -    return notmuch;
> > +    *database = notmuch;
> > +    return status;
> >  }
> 
> Should we check database is non-NULL here?

Sure, why not.  Since one could now imagine using these functions to
create a database without using it or test if a database exists, I
made them handle a NULL pointer gracefully.

> > diff --git a/notmuch-count.c b/notmuch-count.c
> > index 9c2ad7b..2f98128 100644
> > --- a/notmuch-count.c
> > +++ b/notmuch-count.c
> 
> > +    if (notmuch_database_open (notmuch_config_get_database_path (config),
> > +			       NOTMUCH_DATABASE_MODE_READ_ONLY, &notmuch))
> 
> Is it OK to rely on NOTMUCH_STATUS_SUCCESS==0 ?

I decree it so.  Plus, we already do this sort of thing all over the
place.

Thread: