Skip to content

Commit

Permalink
clang-format: set ColumnLimit to 0 and reformat (valkey-io#1045)
Browse files Browse the repository at this point in the history
This commit hopefully improves the formatting of the codebase by setting
ColumnLimit to 0 and hence stopping clang-format from trying to put as
much stuff in one line as possible.

This change enabled us to remove most of `clang-format off` directives
and fixed a bunch of lines that looked like this:

```c
#define KEY \
    VALUE /* comment */
```

Additionally, one pair of `clang-format off` / `clang-format on` had
`clang-format off` as the second comment and hence didn't enable the
formatting for the rest of the file. This commit addresses this issue as
well.

Please tell me if anything in the changes seem off. If everything is
fine, I will add this commit to `.git-blame-ignore-revs` later.

---------

Signed-off-by: Mikhail Koviazin <[email protected]>
  • Loading branch information
mkmkme authored Sep 24, 2024
1 parent 6ce75cd commit af81174
Show file tree
Hide file tree
Showing 62 changed files with 2,107 additions and 2,226 deletions.
2 changes: 1 addition & 1 deletion src/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ BasedOnStyle: LLVM
IndentWidth: 4
TabWidth: 4
UseTab: Never
ColumnLimit: 120
ColumnLimit: 0
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 100
Expand Down
56 changes: 27 additions & 29 deletions src/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3117,37 +3117,35 @@ void aclCommand(client *c) {

addReply(c, shared.ok);
} else if (c->argc == 2 && !strcasecmp(sub, "help")) {
/* clang-format off */
const char *help[] = {
"CAT [<category>]",
" List all commands that belong to <category>, or all command categories",
" when no category is specified.",
"DELUSER <username> [<username> ...]",
" Delete a list of users.",
"DRYRUN <username> <command> [<arg> ...]",
" Returns whether the user can execute the given command without executing the command.",
"GETUSER <username>",
" Get the user's details.",
"GENPASS [<bits>]",
" Generate a secure 256-bit user password. The optional `bits` argument can",
" be used to specify a different size.",
"LIST",
" Show users details in config file format.",
"LOAD",
" Reload users from the ACL file.",
"LOG [<count> | RESET]",
" Show the ACL log entries.",
"SAVE",
" Save the current config to the ACL file.",
"SETUSER <username> <attribute> [<attribute> ...]",
" Create or modify a user with the specified attributes.",
"USERS",
" List all the registered usernames.",
"WHOAMI",
" Return the current connection username.",
NULL
"CAT [<category>]",
" List all commands that belong to <category>, or all command categories",
" when no category is specified.",
"DELUSER <username> [<username> ...]",
" Delete a list of users.",
"DRYRUN <username> <command> [<arg> ...]",
" Returns whether the user can execute the given command without executing the command.",
"GETUSER <username>",
" Get the user's details.",
"GENPASS [<bits>]",
" Generate a secure 256-bit user password. The optional `bits` argument can",
" be used to specify a different size.",
"LIST",
" Show users details in config file format.",
"LOAD",
" Reload users from the ACL file.",
"LOG [<count> | RESET]",
" Show the ACL log entries.",
"SAVE",
" Save the current config to the ACL file.",
"SETUSER <username> <attribute> [<attribute> ...]",
" Create or modify a user with the specified attributes.",
"USERS",
" List all the registered usernames.",
"WHOAMI",
" Return the current connection username.",
NULL,
};
/* clang-format on */
addReplyHelp(c, help);
} else {
addReplySubcommandSyntaxError(c);
Expand Down
12 changes: 6 additions & 6 deletions src/ae.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
#endif
#endif

#define AE_LOCK(eventLoop) \
if ((eventLoop)->flags & AE_PROTECT_POLL) { \
assert(pthread_mutex_lock(&(eventLoop)->poll_mutex) == 0); \
#define AE_LOCK(eventLoop) \
if ((eventLoop)->flags & AE_PROTECT_POLL) { \
assert(pthread_mutex_lock(&(eventLoop)->poll_mutex) == 0); \
}

#define AE_UNLOCK(eventLoop) \
if ((eventLoop)->flags & AE_PROTECT_POLL) { \
assert(pthread_mutex_unlock(&(eventLoop)->poll_mutex) == 0); \
#define AE_UNLOCK(eventLoop) \
if ((eventLoop)->flags & AE_PROTECT_POLL) { \
assert(pthread_mutex_unlock(&(eventLoop)->poll_mutex) == 0); \
}

aeEventLoop *aeCreateEventLoop(int setsize) {
Expand Down
11 changes: 5 additions & 6 deletions src/ae.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@
#define AE_NONE 0 /* No events registered. */
#define AE_READABLE 1 /* Fire when descriptor is readable. */
#define AE_WRITABLE 2 /* Fire when descriptor is writable. */
#define AE_BARRIER \
4 /* With WRITABLE, never fire the event if the \
READABLE event already fired in the same event \
loop iteration. Useful when you want to persist \
things to disk before sending replies, and want \
to do that in a group fashion. */
#define AE_BARRIER 4 /* With WRITABLE, never fire the event if the \
READABLE event already fired in the same event \
loop iteration. Useful when you want to persist \
things to disk before sending replies, and want \
to do that in a group fashion. */

#define AE_FILE_EVENTS (1 << 0)
#define AE_TIME_EVENTS (1 << 1)
Expand Down
40 changes: 19 additions & 21 deletions src/asciilogo.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,23 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

/* clang-format off */
const char *ascii_logo =
" .+^+. \n"
" .+#########+. \n"
" .+########+########+. Valkey %s (%s/%d) %s bit\n"
" .+########+' '+########+. \n"
" .########+' .+. '+########. Running in %s mode\n"
" |####+' .+#######+. '+####| Port: %d\n"
" |###| .+###############+. |###| PID: %ld \n"
" |###| |#####*'' ''*#####| |###| \n"
" |###| |####' .-. '####| |###| \n"
" |###| |###( (@@@) )###| |###| https://valkey.io \n"
" |###| |####. '-' .####| |###| \n"
" |###| |#####*. .*#####| |###| \n"
" |###| '+#####| |#####+' |###| \n"
" |####+. +##| |#+' .+####| \n"
" '#######+ |##| .+########' \n"
" '+###| |##| .+########+' \n"
" '| |####+########+' \n"
" +#########+' \n"
" '+v+' \n\n";
/* clang-format off */
" .+^+. \n"
" .+#########+. \n"
" .+########+########+. Valkey %s (%s/%d) %s bit\n"
" .+########+' '+########+. \n"
" .########+' .+. '+########. Running in %s mode\n"
" |####+' .+#######+. '+####| Port: %d\n"
" |###| .+###############+. |###| PID: %ld \n"
" |###| |#####*'' ''*#####| |###| \n"
" |###| |####' .-. '####| |###| \n"
" |###| |###( (@@@) )###| |###| https://valkey.io \n"
" |###| |####. '-' .####| |###| \n"
" |###| |#####*. .*#####| |###| \n"
" |###| '+#####| |#####+' |###| \n"
" |####+. +##| |#+' .+####| \n"
" '#######+ |##| .+########' \n"
" '+###| |##| .+########+' \n"
" '| |####+########+' \n"
" +#########+' \n"
" '+v+' \n\n";
Loading

0 comments on commit af81174

Please sign in to comment.