[Openais] [PATCH] Remove ~ 100 lint warnings

Steven Dake sdake at redhat.com
Fri Nov 7 00:38:00 PST 2008


Logging in library APIs is prohibited.  One option is to return the
error codes (which are currently not returned).  The reason they aren't
returned at the moment is because the operations should never
theoretically fail.  IE if a handle get operation occurs a put on the
same handle id should always work.

On Fri, 2008-11-07 at 21:13 +1300, angus salkeld wrote:
> Another option is to log these errors so we can see them.
> 
> -Angus
> 
> >>> Steven Dake <sdake at redhat.com> 11/07/08 2:52 PM >>>
> Angus,
> 
> I don't really like this change since a developer may want to check the
> state of the return values from those functions to make sure their
> development code is operating properly.
> 
> The callers should probably be cast (void) before calling the function
> as a solution if they really dont care about the return values.  I know
> there is alot of pain with that sort of solution but it seems the proper
> way to fix the lint complaints.
> 
> regards
> -steve
> 
> On Fri, 2008-11-07 at 14:41 +1300, angus salkeld wrote:
> > The return value to saHandleDestroy and saHandleInstancePut are never checked so return void
> > not cs_error_t.
> > 
> > Regards
> > Angus
> > 
> > ---
> >  include/corosync/ais_util.h |    4 ++--
> >  lib/util.c                  |   14 +++++---------
> >  2 files changed, 7 insertions(+), 11 deletions(-)
> > 
> > diff --git a/include/corosync/ais_util.h b/include/corosync/ais_util.h
> > index 18c8705..ba613a6 100644
> > --- a/include/corosync/ais_util.h
> > +++ b/include/corosync/ais_util.h
> > @@ -101,7 +101,7 @@ saHandleCreate (
> >  	int instanceSize,
> >  	uint64_t *handleOut);
> >  
> > -cs_error_t
> > +void
> >  saHandleDestroy (
> >  	struct saHandleDatabase *handleDatabase,
> >  	uint64_t handle);
> > @@ -112,7 +112,7 @@ saHandleInstanceGet (
> >  	uint64_t handle,
> >  	void **instance);
> >  
> > -cs_error_t
> > +void
> >  saHandleInstancePut (
> >  	struct saHandleDatabase *handleDatabase,
> >  	uint64_t handle);
> > diff --git a/lib/util.c b/lib/util.c
> > index ad61f33..beb463c 100644
> > --- a/lib/util.c
> > +++ b/lib/util.c
> > @@ -609,12 +609,11 @@ saHandleCreate (
> >  }
> >  
> > 
> > -cs_error_t
> > +void
> >  saHandleDestroy (
> >  	struct saHandleDatabase *handleDatabase,
> >  	uint64_t inHandle)
> >  {
> > -	cs_error_t error = CS_OK;
> >  	uint32_t check = inHandle >> 32;
> >  	uint32_t handle = inHandle & 0xffffffff;
> >  
> > @@ -622,8 +621,7 @@ saHandleDestroy (
> >  
> >  	if (check != handleDatabase->handles[handle].check) {
> >  		pthread_mutex_unlock (&handleDatabase->mutex);
> > -		error = CS_ERR_BAD_HANDLE;
> > -		return (error);
> > +		return;
> >  	}
> >  
> >  	handleDatabase->handles[handle].state = SA_HANDLE_STATE_PENDINGREMOVAL;
> > @@ -632,7 +630,7 @@ saHandleDestroy (
> >  
> >  	saHandleInstancePut (handleDatabase, inHandle);
> >  
> > -	return (error);
> > +	return;
> >  }
> >  
> > 
> > @@ -673,20 +671,18 @@ error_exit:
> >  }
> >  
> > 
> > -cs_error_t
> > +void
> >  saHandleInstancePut (
> >  	struct saHandleDatabase *handleDatabase,
> >  	uint64_t inHandle)
> >  {
> >  	void *instance;
> > -	cs_error_t error = CS_OK;
> >  	uint32_t check = inHandle >> 32;
> >  	uint32_t handle = inHandle & 0xffffffff;
> >  
> >  	pthread_mutex_lock (&handleDatabase->mutex);
> >  
> >  	if (check != handleDatabase->handles[handle].check) {
> > -		error = CS_ERR_BAD_HANDLE;
> >  		goto error_exit;
> >  	}
> >  
> > @@ -703,7 +699,7 @@ saHandleInstancePut (
> >  error_exit:
> >  	pthread_mutex_unlock (&handleDatabase->mutex);
> >  
> > -	return (error);
> > +	return;
> >  }
> >  
> > 
> 
> _______________________________________________
> Openais mailing list
> Openais at lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/openais
> 
> _______________________________________________
> Openais mailing list
> Openais at lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/openais



More information about the Openais mailing list