[PATCH 2/2] strbuf: make it clear that suffixcmp() should not be used for sorting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nobody sane uses suffixcmp() for anything but checking with zero,
but it is not very clear from the implementation that it should
not be used for any sorting.

So let's make it clear that the callers should not expect anything
but "does str have sfx as its suffix, yes or no?".

Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx>
---
 strbuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/strbuf.c b/strbuf.c
index 1170d01..9ba50de 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -16,7 +16,7 @@ int suffixcmp(const char *str, const char *suffix)
 	if (len < suflen)
 		return -1;
 	else
-		return strcmp(str + len - suflen, suffix);
+		return !!strcmp(str + len - suflen, suffix);
 }
 
 /*
-- 
1.8.4.1.576.g36ba827.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]