drh / lcc

The lcc retargetable ANSI C compiler
https://drh.github.io/lcc/
2.03k stars 442 forks source link

[PATCH] The unsigned variable 'n' will never be negative so it is either pointless or an error to check if it is. #11

Closed orbitcowboy closed 10 years ago

orbitcowboy commented 10 years ago

Please review the attached patch. The variable 'n' will never be negative so it is either pointless or an error to check if it is.

diff --git a/cpp/unix.c b/cpp/unix.c
index b3db364..400af35 100755
--- a/cpp/unix.c
+++ b/cpp/unix.c
@@ -97,7 +97,7 @@ memmove(void *dp, const void *sp, size_t n)
 {
        unsigned char *cdp, *csp;

-       if (n<=0)
+       if (n==0)
                return 0;
        cdp = dp;
        csp = (unsigned char *)sp;

Best regards and many thanks

Martin Ettl

drh commented 10 years ago

Fixed. Thanks.