Skip to content

Commit bccdf5b

Browse files
committed
Remove > 0 check (tautology)
1 parent 9baa777 commit bccdf5b

File tree

9 files changed

+9
-10
lines changed

9 files changed

+9
-10
lines changed

libc/src/string/memccpy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace LIBC_NAMESPACE_DECL {
1818
LLVM_LIBC_FUNCTION(void *, memccpy,
1919
(void *__restrict dest, const void *__restrict src, int c,
2020
size_t count)) {
21-
if (c > 0) {
21+
if (c) {
2222
LIBC_CRASH_ON_NULLPTR(dest);
2323
LIBC_CRASH_ON_NULLPTR(src);
2424
}

libc/src/string/memchr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ namespace LIBC_NAMESPACE_DECL {
1818

1919
// TODO: Look at performance benefits of comparing words.
2020
LLVM_LIBC_FUNCTION(void *, memchr, (const void *src, int c, size_t n)) {
21-
if (n > 0) {
21+
if (n)
2222
LIBC_CRASH_ON_NULLPTR(src);
23-
}
2423
return internal::find_first_character(
2524
reinterpret_cast<const unsigned char *>(src),
2625
static_cast<unsigned char>(c), n);

libc/src/string/memcmp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
1717

1818
LLVM_LIBC_FUNCTION(int, memcmp,
1919
(const void *lhs, const void *rhs, size_t count)) {
20-
if (count > 0) {
20+
if (count) {
2121
LIBC_CRASH_ON_NULLPTR(lhs);
2222
LIBC_CRASH_ON_NULLPTR(rhs);
2323
}

libc/src/string/memcpy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
1717
LLVM_LIBC_FUNCTION(void *, memcpy,
1818
(void *__restrict dst, const void *__restrict src,
1919
size_t size)) {
20-
if (size > 0) {
20+
if (size) {
2121
LIBC_CRASH_ON_NULLPTR(dst);
2222
LIBC_CRASH_ON_NULLPTR(src);
2323
}

libc/src/string/memmove.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
1717

1818
LLVM_LIBC_FUNCTION(void *, memmove,
1919
(void *dst, const void *src, size_t count)) {
20-
if (count > 0) {
20+
if (count) {
2121
LIBC_CRASH_ON_NULLPTR(dst);
2222
LIBC_CRASH_ON_NULLPTR(src);
2323
}

libc/src/string/strncat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace LIBC_NAMESPACE_DECL {
1919
LLVM_LIBC_FUNCTION(char *, strncat,
2020
(char *__restrict dest, const char *__restrict src,
2121
size_t count)) {
22-
if (count > 0) {
22+
if (count) {
2323
LIBC_CRASH_ON_NULLPTR(dest);
2424
LIBC_CRASH_ON_NULLPTR(src);
2525
}

libc/src/string/strncmp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace LIBC_NAMESPACE_DECL {
1919

2020
LLVM_LIBC_FUNCTION(int, strncmp,
2121
(const char *left, const char *right, size_t n)) {
22-
if (n > 0) {
22+
if (n) {
2323
LIBC_CRASH_ON_NULLPTR(left);
2424
LIBC_CRASH_ON_NULLPTR(right);
2525
}

libc/src/string/strncpy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace LIBC_NAMESPACE_DECL {
1818
LLVM_LIBC_FUNCTION(char *, strncpy,
1919
(char *__restrict dest, const char *__restrict src,
2020
size_t n)) {
21-
if (n > 0) {
21+
if (n) {
2222
LIBC_CRASH_ON_NULLPTR(dest);
2323
LIBC_CRASH_ON_NULLPTR(src);
2424
}

libc/src/string/strsep.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ namespace LIBC_NAMESPACE_DECL {
1717
LLVM_LIBC_FUNCTION(char *, strsep,
1818
(char **__restrict stringp, const char *__restrict delim)) {
1919
LIBC_CRASH_ON_NULLPTR(stringp);
20-
LIBC_CRASH_ON_NULLPTR(delim);
2120
if (!*stringp)
2221
return nullptr;
22+
LIBC_CRASH_ON_NULLPTR(delim);
2323
return internal::string_token<false>(*stringp, delim, stringp);
2424
}
2525

0 commit comments

Comments
 (0)