Fix traffic analyzer developer build

Holger Hetterich hhetter at novell.com
Fri Mar 19 08:00:09 MDT 2010


Am Donnerstag, 18. März 2010 23:30:42 schrieb Jeremy Allison:
> On Thu, Mar 18, 2010 at 11:15:02PM +0100, Holger Hetterich wrote:
> >  static char *smb_traffic_analyzer_create_header( TALLOC_CTX *ctx,
> > 
> > -	const char *state_flags, size_t data_len)
> > +	const char *state_flags, int data_len)
> > 
> >  {
> > 
> > -	char *header = talloc_asprintf( ctx, "V2.%s%017u",
> > +	char *header = talloc_asprintf( ctx, "V2.%s%017d",
> > 
> >  					state_flags, data_len);
> 
> In cases like this, rather than change data_len from an
> unsigned size_t to a signed int, for a value that can
> never be negative, just to fix a talloc_asprintf format,
> just add a cast to the asprintf. i.e. the change should
> 

Hi Jeremy, thank you for looking at this!

With the argumentation used above, I could cast almost all
ints in the asprintf format, because most of the values will
never be negative. However it was my original intention to not
have to cast all the values inside the asprintf format. :)
Also, nearly none of the values will ever  be in the range where
unsigned/signed does matter. The only exception I see is theoretically
the write/pwrite/read/pread call, that returns a size_t as the
number of bytes that have been transferred. And even there
it's unlikely I'll hit the borders. 

So in this patch, I am using a size_t for write,read,pread,pwrite,
and cast it to unsigned int.

Additionally, in this patch I've added the 
vfs_fn_pointer for the smb_traffic_analyzer_rmdir function to 
vfs_smb_traffic_analyzer_fns. I've missed that in the first
patch.

Holger


> be:
> > -                                     state_flags, data_len);
> > +                                     state_flags, (unsigned
> > int)data_len);
> 
> instead of changing the aprintf format from "%u" -> "%d".
> 
> Jeremy.


-- 
Holger Hetterich, hhetter at novell.com, 
  SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
   Maxfeldstr. 5, 90409 Nürnberg, Germany
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-s3-vfs_smb_traffic_analyzer.c-fix-warnings-with-conf.patch
Type: text/x-patch
Size: 6999 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20100319/91372e17/attachment.bin>


More information about the samba-technical mailing list