forked from facebook/watchman
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libart: better defined behavior when a full prefix key is encountered
Summary: a facet of the libart implementation that is undocumented except for a series of issues (linked below) is this: an inserted key must not be a full prefix of another key that is already stored in the tree. The recommendation is to store keys that have a terminator character. armon/libart#4 armon/libart#12 armon/libart#14 armon/libart#17 Our usage in watchman can't guarantee to provide a NUL-terminated input, so this diff adjusts the key comparison routines to generate an implicit or synthetic NUL terminator character when comparing one character beyond the end of a key, and by asserting (or allowing ASAN to complain) if we try to look more than 1 character beyond the end. I also tidied up the function signatures of a couple of matching functions so that the semantics are clearer (return boolean true for success rather than integer 0) and removed some redundant casts when invoking callbacks. Test Plan: added an explicit test for the full-prefix issue. Built with -fsanitize=address and ran the integration tests as well as the sparse/unsparse checks I've been using for the pending list changes.
- Loading branch information
Showing
9 changed files
with
247 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* Copyright 2016-present Facebook, Inc. | ||
* Licensed under the Apache License, Version 2.0. */ | ||
|
||
#include "watchman.h" | ||
|
||
// These are logging stubs to facilitate testing code that pulls in w_log | ||
// either directly or indirectly. | ||
|
||
void w_request_shutdown(void) {} | ||
|
||
bool w_should_log_to_clients(int level) | ||
{ | ||
unused_parameter(level); | ||
return false; | ||
} | ||
|
||
void w_log_to_clients(int level, const char *buf) | ||
{ | ||
unused_parameter(level); | ||
unused_parameter(buf); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.