[PATCH] Fix compiler warning

Anoop C S anoopcs at redhat.com
Wed Oct 21 03:51:09 UTC 2015


On Tue, 2015-10-20 at 09:47 -0700, Jeremy Allison wrote:
> On Tue, Oct 20, 2015 at 12:44:57PM +0530, Anoop C S wrote:
> > On Fri, 2015-10-16 at 10:33 -0700, Jeremy Allison wrote:
> > > On Fri, Oct 16, 2015 at 01:38:38PM +0200, Michael Adam wrote:
> > > > On 2015-10-16 at 16:58 +0530, Anoop C S wrote:
> > > > > Hi,
> > > > > 
> > > > > Please see the attached patch which fixes a compiler warning
> > > > > from
> > > > > sysquotas_nfs.c
> > > > 
> > > > To me, this looks good. I also already discussed this with
> > > > Anoop.
> > > > All definitions of the enum I can find start with 1.
> > > > But I don't know all the history. This code originally comes
> > > > from
> > > > source3/smbd/quotas.c, added in 2001:
> > > > f439f72ceec665dbd1eae367eb5d7302d8a3338d
> > > > Has the definition been different back then? ...
> > > > 
> > > > So I tentatively give my review.
> > > > (Barring explanation why we need the 0 case... ;-)
> > > 
> > > No, it's good. If you look at the zero case it's
> > > merely being used as a different error case, which is already
> > > correctly handled in default:
> > > 
> > > I'll push. Thanks Anoop !
> > > 
> > > > If this is OK, then we need the corresponding patch to
> > > > smbd/quotas.c, Anoop.
> > > 
> > > Yes please !
> > 
> > I have attached the similar patch for smbd/quotas.c. Do we need to
> > separate out different switch cases for quota status here with
> > corresponding DEBUG messages?
> 
> This patch doesn't work as-is, as it removes the 'goto out;'
> part which isn't present in default:
> 
> I think this patch plus an additional change to the
> error message and additional 'goto out;' in default:
> would be better.
> 

Thank you for pointing out the missing goto. Please see the attached
patch which reflects the changes mentioned above.

--Anoop C S.

> Thanks !
> 
> Jeremy.
> 
> > From b29782609531545e16b274d8f67850eb3e5db855 Mon Sep 17 00:00:00
> > 2001
> > From: Anoop C S <anoopcs at redhat.com>
> > Date: Tue, 20 Oct 2015 11:23:23 +0530
> > Subject: [PATCH] smbd/quotas: Remove invalid quota status switch
> > case
> > 
> > getquota_rslt structure from rquota.h defines the enum
> > named status whose values start from 1. But in quotas.c
> > we have an invalid check for status 0. This change is
> > to remove that particular switch case.
> > 
> > Signed-off-by: Anoop C S <anoopcs at redhat.com>
> > ---
> >  source3/smbd/quotas.c | 11 +++--------
> >  1 file changed, 3 insertions(+), 8 deletions(-)
> > 
> > diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c
> > index c64b63a..77d70b4 100644
> > --- a/source3/smbd/quotas.c
> > +++ b/source3/smbd/quotas.c
> > @@ -171,17 +171,12 @@ static bool nfs_quotas(char *nfspath, uid_t
> > euser_id, uint64_t *bsize, uint64_t
> >  	}
> >  
> >  	/*
> > -	 * gqr.status returns 0 if the rpc call fails, 1 if quotas
> > exist, 2 if there is
> > -	 * no quota set, and 3 if no permission to get the quota. 
> >  If 0 or 3 return
> > -	 * something sensible.
> > +	 * gqr.status returns 1 if quotas exist, 2 if there is
> > +	 * no quota set, and 3 if no permission to get the quota.
> > +         * If 3, return something sensible.
> >  	 */
> >  
> >  	switch (gqr.status) {
> > -	case 0:
> > -		DEBUG(9,("nfs_quotas: Remote Quotas Failed!  Error
> > \"%i\" \n", gqr.status));
> > -		ret = False;
> > -		goto out;
> > -
> >  	case 1:
> >  		DEBUG(9,("nfs_quotas: Good quota data\n"));
> >  		D.dqb_bsoftlimit =
> > gqr.getquota_rslt_u.gqr_rquota.rq_bsoftlimit;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-smbd-quotas-Remove-invalid-quota-status-switch-case.patch
Type: text/x-patch
Size: 1967 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20151021/18189a9e/0001-smbd-quotas-Remove-invalid-quota-status-switch-case.bin>


More information about the samba-technical mailing list