summaryrefslogtreecommitdiff
path: root/src/tree.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-02-16 11:29:46 +0000
committerPatrick Steinhardt <ps@pks.im>2018-02-16 11:42:28 +0000
commit06b8a40f8b5eb1188a326d90705945b3a9b6a19f (patch)
tree3afb161bf4065ff0bdbdcb5f08171a677a507e1a /src/tree.c
parent7c6e91759facc76e3f99373b759b4506fd700608 (diff)
downloadlibgit2-06b8a40f8b5eb1188a326d90705945b3a9b6a19f.tar.gz
Explicitly mark fallthrough cases with comments
A lot of compilers nowadays generate warnings when there are cases in a switch statement which implicitly fall through to the next case. To avoid this warning, the last line in the case that is falling through can have a comment matching a regular expression, where one possible comment body would be `/* fall through */`. An alternative to the comment would be an explicit attribute like e.g. `[[clang::fallthrough]` or `__attribute__ ((fallthrough))`. But GCC only introduced support for such an attribute recently with GCC 7. Thus, and also because the fallthrough comment is supported by most compilers, we settle for using comments instead. One shortcoming of that method is that compilers are very strict about that. Most interestingly, that comment _really_ has to be the last line. In case a closing brace follows the comment, the heuristic will fail.
Diffstat (limited to 'src/tree.c')
-rw-r--r--src/tree.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/tree.c b/src/tree.c
index 6a136a6b7..fdf36f850 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -957,7 +957,7 @@ int git_tree_entry_bypath(
* walking down the path */
if (path[filename_len + 1] != '\0')
break;
-
+ /* fall through */
case '\0':
/* If there are no more components in the path, return
* this entry */