Re: [PATCH] Add git-imap-send.

From: Andreas Ericsson <ae@op5.se>
Date: 2006-03-09 22:39:58
Johannes Schindelin wrote:
> Hi,
> 
> On Thu, 9 Mar 2006, Junio C Hamano wrote:
> 
> 
>>Mike McCormack <mike@codeweavers.com> writes:
>>
>>
>>>+		if (!memcmp( "imaps:", val, 6 )) {
>>>+			if (!memcmp( "imap:", val, 5 ))
>>
>>Is val always longer than 5 or 6 bytes here?
> 
> 
> That does not matter, since they are strings, and the memcmp should not 
> look further if they are shorter (because the comparison to '\0' failed 
> already).
> 

That's what strcmp() does. memcmp() walks the lenghth even if it 
encounters nul bytes. Perhaps you confuse it with strncmp()?


> However, if !memcmp("imaps:", val, 6), it means that val starts with 
> the string "imaps:", right? Then !memcmp("imap:", val, 5) must always 
> fail, no?
> 

Yes. Recent gcc's will recognize it as dead code and remove it. It's 
still ugly though.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Thu Mar 09 22:40:32 2006

This archive was generated by hypermail 2.1.8 : 2006-03-09 22:40:45 EST