Re: [PATCH 2/7] odb/source-inmemory: signal missing objects via positive return

Patrick Steinhardt <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
On Tue, Aug 18, 2026 at 11:05:33AM -0700, Junio C Hamano wrote:
> Patrick Steinhardt <[email protected]> writes:
> 
> > The in-memory source returns a negative value from its
> > `read_object_info()` callback when the object in question does not
> > exist. Adapt the callback to return a positive value for missing objects
> > according to the new calling convention.
> >
> > Signed-off-by: Patrick Steinhardt <[email protected]>
> > ---
> >  odb/source-inmemory.c         | 2 +-
> >  t/unit-tests/u-odb-inmemory.c | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/odb/source-inmemory.c b/odb/source-inmemory.c
> > index 3e71611b8e..57183daf4d 100644
> > --- a/odb/source-inmemory.c
> > +++ b/odb/source-inmemory.c
> > @@ -66,7 +66,7 @@ static int odb_source_inmemory_read_object_info(struct odb_source *source,
> >  
> >  	object = find_cached_object(inmemory, oid);
> >  	if (!object)
> > -		return -1;
> > +		return 1;
> 
> Let's not define "any positive value means this single thing: it
> does not exist" and then return a mysterious and unspecified hard
> coded constant like this.  Instead perhaps something along this
> line?
> 
>     enum odb_roi_status {
> 	ODB_ROI_SUCCESS = 0,
> 	ODB_ROI_MISSING = 1,
> 	ODB_ROI_IO_ERROR = -1,
> 	...
>     };
> 
> As I already said, I personally prefer to define MISSING also as
> a negative value.

Fair enough, will adapt.

Patrick
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.