Ethereal-dev: Re: [Ethereal-dev] Tethereal -z io,users,ip has stats in wrong order

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <guy@xxxxxxxxxx>
Date: Mon, 19 May 2003 12:10:10 -0700
On Mon, May 19, 2003 at 12:01:36PM +0200, martin.regner@xxxxxxxxx wrote:
> I think that:

	...

> should be changed to:
> 	if(memcmp(&iph->ip_src,iui->addr1,4)){  

	...

And I think it should be changed to

	if(memcmp(&iph->ip_src,iui->addr1,4) != 0){  

so that the line in question contains a comparison operator, making it
clear what comparison is being done.

> memcmp returns 0 if they are equal.

...and a negative value if the first argument is less than the second,
and a positive value if the first argument is greater than the second,
so that to compare two byte arrays using a particular comparison
operator, you use "memcmp()" and then use the same comparison operator
to compare the result of "memcmp()" with 0.

The same applies to string comparison routines; they don't return a
Boolean, they return an integer.