Skip to content

Commit 385aff0

Browse files
yuxuanchen1997meta-codesync[bot]
authored andcommitted
Fix -Wnonnull warning in folly/
Summary: libc++ 21 enables stricter `-Wnonnull` diagnostics. `std::string::append` is annotated `nonnull`, so passing a potentially-null pointer is a hard error even when guarded by a null check on an alias. Fix by passing the already-checked local variable `c` instead of the original parameter `value`. Reviewed By: lexprfuncall Differential Revision: D94578921 fbshipit-source-id: 15b9b4e87ccf4d8a477672d70eb329bdcb0724f9
1 parent 3a6c4c6 commit 385aff0

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

  • third-party/folly/src/folly

third-party/folly/src/folly/Conv.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,8 @@ typename std::enable_if<
431431
toAppend(Src value, Tgt* result) {
432432
// Treat null pointers like an empty string, as in:
433433
// operator<<(std::ostream&, const char*).
434-
const char* c = value;
435-
if (c) {
436-
result->append(value);
434+
if (const char* c = value) {
435+
result->append(c);
437436
}
438437
}
439438

0 commit comments

Comments
 (0)