diff options
| author | Matt Spinler <spinler@us.ibm.com> | 2018-09-19 13:23:13 -0500 |
|---|---|---|
| committer | Matt Spinler <spinler@us.ibm.com> | 2018-09-19 14:32:34 -0500 |
| commit | cc6ee9cb98a3a8c6020cef9a0debbf2c35f50f7f (patch) | |
| tree | cc8d0dbe61df276cd982389f01fb9eb618fe0987 | |
| parent | d6729ea39d443bf62a27bbf64ef6bc7a123125c8 (diff) | |
| download | phosphor-objmgr-cc6ee9cb98a3a8c6020cef9a0debbf2c35f50f7f.tar.gz phosphor-objmgr-cc6ee9cb98a3a8c6020cef9a0debbf2c35f50f7f.zip | |
clang-format updates
Pick up latest clang-format from the docs repo and rerun
with clang-format-6.0
Change-Id: I2f0411bb01d78f096563d63b197ce12daf43bcbd
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
| -rw-r--r-- | .clang-format | 24 | ||||
| -rw-r--r-- | fail-monitor/argument.cpp | 11 | ||||
| -rw-r--r-- | fail-monitor/argument.hpp | 7 | ||||
| -rw-r--r-- | fail-monitor/main.cpp | 5 | ||||
| -rw-r--r-- | fail-monitor/monitor.cpp | 9 | ||||
| -rw-r--r-- | fail-monitor/monitor.hpp | 6 | ||||
| -rw-r--r-- | libmapper/app.c | 42 | ||||
| -rw-r--r-- | libmapper/mapper.c | 174 | ||||
| -rw-r--r-- | libmapper/mapper.h | 22 | ||||
| -rw-r--r-- | libmapper/workaround/systemd.h | 4 |
10 files changed, 163 insertions, 141 deletions
diff --git a/.clang-format b/.clang-format index 37469de..8c5278e 100644 --- a/.clang-format +++ b/.clang-format @@ -17,7 +17,7 @@ AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false +AlwaysBreakTemplateDeclarations: true BinPackArguments: true BinPackParameters: true BraceWrapping: @@ -42,12 +42,25 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true -DerivePointerAlignment: true -PointerAlignment: Left +DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false FixNamespaceComments: true ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^[<"](gtest|gmock)' + Priority: 5 + - Regex: '^"config.h"' + Priority: -1 + - Regex: '^".*\.hpp"' + Priority: 1 + - Regex: '^<.*\.h>' + Priority: 2 + - Regex: '^<.*' + Priority: 3 + - Regex: '.*' + Priority: 4 IndentCaseLabels: true IndentWidth: 4 IndentWrappedFunctionNames: true @@ -65,9 +78,10 @@ PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Right +PointerAlignment: Left ReflowComments: true -SortIncludes: false +SortIncludes: true +SortUsingDeclarations: true SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements diff --git a/fail-monitor/argument.cpp b/fail-monitor/argument.cpp index daf0177..33194ce 100644 --- a/fail-monitor/argument.cpp +++ b/fail-monitor/argument.cpp @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "argument.hpp" + +#include <algorithm> #include <iostream> #include <iterator> -#include <algorithm> -#include "argument.hpp" namespace phosphor { @@ -85,6 +86,6 @@ const char* ArgumentParser::optionStr = "s:a:t:h?"; const std::string ArgumentParser::trueString = "true"; const std::string ArgumentParser::emptyString = ""; -} -} -} +} // namespace failure +} // namespace unit +} // namespace phosphor diff --git a/fail-monitor/argument.hpp b/fail-monitor/argument.hpp index 00f3755..8648ddd 100644 --- a/fail-monitor/argument.hpp +++ b/fail-monitor/argument.hpp @@ -1,6 +1,7 @@ #pragma once #include <getopt.h> + #include <map> #include <string> @@ -62,6 +63,6 @@ class ArgumentParser /** @brief optstring as needed by getopt_long */ static const char* optionStr; }; -} -} -} +} // namespace failure +} // namespace unit +} // namespace phosphor diff --git a/fail-monitor/main.cpp b/fail-monitor/main.cpp index 2c3bc59..90c6126 100644 --- a/fail-monitor/main.cpp +++ b/fail-monitor/main.cpp @@ -20,11 +20,12 @@ * then it will either stop or start the target unit, depending * on the command line arguments. */ -#include <iostream> -#include <map> #include "argument.hpp" #include "monitor.hpp" +#include <iostream> +#include <map> + using namespace phosphor::unit::failure; /** diff --git a/fail-monitor/monitor.cpp b/fail-monitor/monitor.cpp index 9a0722a..51eb1f3 100644 --- a/fail-monitor/monitor.cpp +++ b/fail-monitor/monitor.cpp @@ -13,9 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include <phosphor-logging/log.hpp> #include "monitor.hpp" +#include <phosphor-logging/log.hpp> + namespace phosphor { namespace unit @@ -115,6 +116,6 @@ void Monitor::runTargetAction() throw std::runtime_error("Failed to run action on the target unit"); } } -} -} -} +} // namespace failure +} // namespace unit +} // namespace phosphor diff --git a/fail-monitor/monitor.hpp b/fail-monitor/monitor.hpp index 0c2b33a..df8a30a 100644 --- a/fail-monitor/monitor.hpp +++ b/fail-monitor/monitor.hpp @@ -102,6 +102,6 @@ class Monitor */ const Action action; }; -} -} -} +} // namespace failure +} // namespace unit +} // namespace phosphor diff --git a/libmapper/app.c b/libmapper/app.c index 681c4a7..14d8ab0 100644 --- a/libmapper/app.c +++ b/libmapper/app.c @@ -14,23 +14,25 @@ * limitations under the License. */ #include "config.h" -#include <stdlib.h> + #include <stdio.h> +#include <stdlib.h> #include <systemd/sd-bus.h> #include <systemd/sd-event.h> + #include "mapper.h" -static void quit(int r, void *loop) +static void quit(int r, void* loop) { - sd_event_exit((sd_event *)loop, r); + sd_event_exit((sd_event*)loop, r); } -static int wait_main(int argc, char *argv[]) +static int wait_main(int argc, char* argv[]) { int r; - sd_bus *conn = NULL; - sd_event *loop = NULL; - mapper_async_wait *wait = NULL; + sd_bus* conn = NULL; + sd_event* loop = NULL; + mapper_async_wait* wait = NULL; if (argc < 3) { @@ -81,17 +83,17 @@ finish: exit(r < 0 ? EXIT_FAILURE : EXIT_SUCCESS); } -static int subtree_main(int argc, char *argv[]) +static int subtree_main(int argc, char* argv[]) { int r = 0; int op = 0; - static const char *token = ":"; - char *tmp = NULL; - char *namespace = NULL; - char *interface = NULL; - sd_bus *conn = NULL; - sd_event *loop = NULL; - mapper_async_subtree *subtree = NULL; + static const char* token = ":"; + char* tmp = NULL; + char* namespace = NULL; + char* interface = NULL; + sd_bus* conn = NULL; + sd_event* loop = NULL; + mapper_async_subtree* subtree = NULL; if (argc != 3) { @@ -154,11 +156,11 @@ finish: } /* print out the distinct dbus service name for the input dbus path */ -static int get_service_main(int argc, char *argv[]) +static int get_service_main(int argc, char* argv[]) { int r; - sd_bus *conn = NULL; - char *service = NULL; + sd_bus* conn = NULL; + char* service = NULL; if (argc != 3) { @@ -187,9 +189,9 @@ finish: exit(r < 0 ? EXIT_FAILURE : EXIT_SUCCESS); } -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - static const char *usage = + static const char* usage = "Usage: %s {COMMAND} ...\n" "\nCOMMANDS:\n" " wait wait for the specified objects to appear on the " diff --git a/libmapper/mapper.c b/libmapper/mapper.c index 399c475..0f93937 100644 --- a/libmapper/mapper.c +++ b/libmapper/mapper.c @@ -14,29 +14,31 @@ * limitations under the License. */ #include "config.h" + +#include "mapper.h" + +#include <errno.h> #include <stdbool.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdio.h> -#include <errno.h> -#include <unistd.h> #include <sys/timerfd.h> #include <systemd/sd-bus.h> #include <systemd/sd-event.h> -#include "mapper.h" +#include <unistd.h> -static const char *async_wait_introspection_match = +static const char* async_wait_introspection_match = "type='signal'," "sender='xyz.openbmc_project.ObjectMapper'," "interface='xyz.openbmc_project.ObjectMapper.Private'," "member='IntrospectionComplete'"; -static const char *async_wait_interfaces_added_match = +static const char* async_wait_interfaces_added_match = "type='signal'," "interface='org.freedesktop.DBus.ObjectManager'," "member='InterfacesAdded'"; -static const char *interfaces_removed_match = +static const char* interfaces_removed_match = "type='signal'," "interface='org.freedesktop.DBus.ObjectManager'," "member='InterfacesRemoved'"; @@ -46,14 +48,14 @@ static const uint64_t mapper_busy_delay_interval_usec = 1000000; struct mapper_async_wait { - char **objs; - void (*callback)(int, void *); - void *userdata; - sd_event *loop; - sd_bus *conn; - sd_bus_slot *introspection_slot; - sd_bus_slot *intf_slot; - int *status; + char** objs; + void (*callback)(int, void*); + void* userdata; + sd_event* loop; + sd_bus* conn; + sd_bus_slot* introspection_slot; + sd_bus_slot* intf_slot; + int* status; int count; int finished; int r; @@ -61,46 +63,44 @@ struct mapper_async_wait struct async_wait_callback_data { - mapper_async_wait *wait; - const char *path; - sd_event_source *event_source; + mapper_async_wait* wait; + const char* path; + sd_event_source* event_source; int retry; }; struct mapper_async_subtree { - char *namespace; - char *interface; - void (*callback)(int, void *); - void *userdata; - sd_event *loop; - sd_bus *conn; - sd_bus_slot *slot; - sd_event_source *event_source; + char* namespace; + char* interface; + void (*callback)(int, void*); + void* userdata; + sd_event* loop; + sd_bus* conn; + sd_bus_slot* slot; + sd_event_source* event_source; int finished; int op; int retry; }; -static int async_wait_match_introspection_complete(sd_bus_message *, void *, - sd_bus_error *); -static int async_wait_check_done(mapper_async_wait *); -static void async_wait_done(int r, mapper_async_wait *); -static int async_wait_get_objects(mapper_async_wait *); -static int async_wait_getobject_callback(sd_bus_message *, void *, - sd_bus_error *); - -static int async_subtree_match_callback(sd_bus_message *, void *, - sd_bus_error *); -static void async_subtree_done(int r, mapper_async_subtree *); -static int async_subtree_getpaths(mapper_async_subtree *); -static int async_subtree_getpaths_callback(sd_bus_message *, void *, - sd_bus_error *); - -static int sarraylen(char *array[]) +static int async_wait_match_introspection_complete(sd_bus_message*, void*, + sd_bus_error*); +static int async_wait_check_done(mapper_async_wait*); +static void async_wait_done(int r, mapper_async_wait*); +static int async_wait_get_objects(mapper_async_wait*); +static int async_wait_getobject_callback(sd_bus_message*, void*, sd_bus_error*); + +static int async_subtree_match_callback(sd_bus_message*, void*, sd_bus_error*); +static void async_subtree_done(int r, mapper_async_subtree*); +static int async_subtree_getpaths(mapper_async_subtree*); +static int async_subtree_getpaths_callback(sd_bus_message*, void*, + sd_bus_error*); + +static int sarraylen(char* array[]) { int count = 0; - char **p = array; + char** p = array; while (*p != NULL) { @@ -111,9 +111,9 @@ static int sarraylen(char *array[]) return count; } -static void sarrayfree(char *array[]) +static void sarrayfree(char* array[]) { - char **p = array; + char** p = array; while (*p != NULL) { free(*p); @@ -122,11 +122,11 @@ static void sarrayfree(char *array[]) free(array); } -static char **sarraydup(char *array[]) +static char** sarraydup(char* array[]) { int count = sarraylen(array); int i; - char **ret = NULL; + char** ret = NULL; ret = malloc(sizeof(*ret) * count); if (!ret) @@ -146,12 +146,12 @@ error: return NULL; } -static int async_wait_timeout_callback(sd_event_source *s, uint64_t usec, - void *userdata) +static int async_wait_timeout_callback(sd_event_source* s, uint64_t usec, + void* userdata) { int r; - struct async_wait_callback_data *data = userdata; - mapper_async_wait *wait = data->wait; + struct async_wait_callback_data* data = userdata; + mapper_async_wait* wait = data->wait; sd_event_source_unref(data->event_source); r = sd_bus_call_method_async(wait->conn, NULL, MAPPER_BUSNAME, MAPPER_PATH, @@ -167,12 +167,12 @@ static int async_wait_timeout_callback(sd_event_source *s, uint64_t usec, return 0; } -static int async_wait_getobject_callback(sd_bus_message *m, void *userdata, - sd_bus_error *e) +static int async_wait_getobject_callback(sd_bus_message* m, void* userdata, + sd_bus_error* e) { int i, r; - struct async_wait_callback_data *data = userdata; - mapper_async_wait *wait = data->wait; + struct async_wait_callback_data* data = userdata; + mapper_async_wait* wait = data->wait; uint64_t next_retry; if (wait->finished) @@ -226,10 +226,10 @@ exit: return 0; } -static int async_wait_get_objects(mapper_async_wait *wait) +static int async_wait_get_objects(mapper_async_wait* wait) { int i, r; - struct async_wait_callback_data *data = NULL; + struct async_wait_callback_data* data = NULL; for (i = 0; i < wait->count; ++i) { @@ -255,12 +255,12 @@ static int async_wait_get_objects(mapper_async_wait *wait) return 0; } -static int async_wait_match_introspection_complete(sd_bus_message *m, void *w, - sd_bus_error *e) +static int async_wait_match_introspection_complete(sd_bus_message* m, void* w, + sd_bus_error* e) { int r; - mapper_async_wait *wait = w; + mapper_async_wait* wait = w; if (wait->finished) return 0; @@ -271,7 +271,7 @@ static int async_wait_match_introspection_complete(sd_bus_message *m, void *w, return 0; } -static void async_wait_done(int r, mapper_async_wait *w) +static void async_wait_done(int r, mapper_async_wait* w) { if (w->finished) return; @@ -284,7 +284,7 @@ static void async_wait_done(int r, mapper_async_wait *w) w->callback(r, w->userdata); } -static int async_wait_check_done(mapper_async_wait *w) +static int async_wait_check_done(mapper_async_wait* w) { int i; @@ -298,19 +298,19 @@ static int async_wait_check_done(mapper_async_wait *w) return 1; } -void mapper_wait_async_free(mapper_async_wait *w) +void mapper_wait_async_free(mapper_async_wait* w) { free(w->status); sarrayfree(w->objs); free(w); } -int mapper_wait_async(sd_bus *conn, sd_event *loop, char *objs[], - void (*callback)(int, void *), void *userdata, - mapper_async_wait **w) +int mapper_wait_async(sd_bus* conn, sd_event* loop, char* objs[], + void (*callback)(int, void*), void* userdata, + mapper_async_wait** w) { int r; - mapper_async_wait *wait = NULL; + mapper_async_wait* wait = NULL; wait = malloc(sizeof(*wait)); if (!wait) @@ -383,11 +383,11 @@ free_wait: return r; } -static int async_subtree_timeout_callback(sd_event_source *s, uint64_t usec, - void *userdata) +static int async_subtree_timeout_callback(sd_event_source* s, uint64_t usec, + void* userdata) { int r; - struct mapper_async_subtree *subtree = userdata; + struct mapper_async_subtree* subtree = userdata; sd_event_source_unref(subtree->event_source); r = sd_bus_call_method_async( @@ -400,11 +400,11 @@ static int async_subtree_timeout_callback(sd_event_source *s, uint64_t usec, return 0; } -static int async_subtree_getpaths_callback(sd_bus_message *m, void *userdata, - sd_bus_error *e) +static int async_subtree_getpaths_callback(sd_bus_message* m, void* userdata, + sd_bus_error* e) { int r; - struct mapper_async_subtree *subtree = userdata; + struct mapper_async_subtree* subtree = userdata; uint64_t next_retry; if (subtree->finished) @@ -476,7 +476,7 @@ exit: return 0; } -static int async_subtree_getpaths(mapper_async_subtree *subtree) +static int async_subtree_getpaths(mapper_async_subtree* subtree) { int r = 0; @@ -495,12 +495,12 @@ static int async_subtree_getpaths(mapper_async_subtree *subtree) return 0; } -static int async_subtree_match_callback(sd_bus_message *m, void *t, - sd_bus_error *e) +static int async_subtree_match_callback(sd_bus_message* m, void* t, + sd_bus_error* e) { int r; - mapper_async_subtree *subtree = t; + mapper_async_subtree* subtree = t; if (subtree->finished) return 0; @@ -511,7 +511,7 @@ static int async_subtree_match_callback(sd_bus_message *m, void *t, return 0; } -static void async_subtree_done(int r, mapper_async_subtree *t) +static void async_subtree_done(int r, mapper_async_subtree* t) { if (t->finished) return; @@ -523,12 +523,12 @@ static void async_subtree_done(int r, mapper_async_subtree *t) t->callback(r, t->userdata); } -int mapper_subtree_async(sd_bus *conn, sd_event *loop, char *namespace, - char *interface, void (*callback)(int, void *), - void *userdata, mapper_async_subtree **t, int op) +int mapper_subtree_async(sd_bus* conn, sd_event* loop, char* namespace, + char* interface, void (*callback)(int, void*), + void* userdata, mapper_async_subtree** t, int op) { int r = 0; - mapper_async_subtree *subtree = NULL; + mapper_async_subtree* subtree = NULL; subtree = malloc(sizeof(*subtree)); if (!subtree) @@ -579,9 +579,9 @@ free_subtree: return r; } -int mapper_get_object(sd_bus *conn, const char *obj, sd_bus_message **reply) +int mapper_get_object(sd_bus* conn, const char* obj, sd_bus_message** reply) { - sd_bus_message *request = NULL; + sd_bus_message* request = NULL; int r, retry = 0; r = sd_bus_message_new_method_call(conn, &request, MAPPER_BUSNAME, @@ -621,10 +621,10 @@ exit: return r; } -int mapper_get_service(sd_bus *conn, const char *obj, char **service) +int mapper_get_service(sd_bus* conn, const char* obj, char** service) { - sd_bus_message *reply = NULL; - const char *tmp; + sd_bus_message* reply = NULL; + const char* tmp; int r; r = mapper_get_object(conn, obj, &reply); diff --git a/libmapper/mapper.h b/libmapper/mapper.h index 854f40c..5b596a6 100644 --- a/libmapper/mapper.h +++ b/libmapper/mapper.h @@ -4,19 +4,21 @@ #ifdef __cplusplus extern "C" { #endif -typedef enum mapper_operation { MAPPER_OP_REMOVE = 1 } mapper_operation; +typedef enum mapper_operation +{ + MAPPER_OP_REMOVE = 1 +} mapper_operation; typedef struct mapper_async_wait mapper_async_wait; typedef struct mapper_async_subtree mapper_async_subtree; -void mapper_wait_async_free(mapper_async_wait *); -void mapper_subtree_async_free(mapper_async_subtree *); +void mapper_wait_async_free(mapper_async_wait*); +void mapper_subtree_async_free(mapper_async_subtree*); -int mapper_wait_async(sd_bus *, sd_event *, char *[], void (*)(int, void *), - void *, mapper_async_wait **); -int mapper_subtree_async(sd_bus *, sd_event *, char *, char *, - void (*)(int, void *), void *, mapper_async_subtree **, - int); -int mapper_get_service(sd_bus *conn, const char *obj, char **service); -int mapper_get_object(sd_bus *conn, const char *obj, sd_bus_message **reply); +int mapper_wait_async(sd_bus*, sd_event*, char* [], void (*)(int, void*), void*, + mapper_async_wait**); +int mapper_subtree_async(sd_bus*, sd_event*, char*, char*, void (*)(int, void*), + void*, mapper_async_subtree**, int); +int mapper_get_service(sd_bus* conn, const char* obj, char** service); +int mapper_get_object(sd_bus* conn, const char* obj, sd_bus_message** reply); #ifdef __cplusplus } #endif diff --git a/libmapper/workaround/systemd.h b/libmapper/workaround/systemd.h index 51fb2e3..5d336ca 100644 --- a/libmapper/workaround/systemd.h +++ b/libmapper/workaround/systemd.h @@ -1,8 +1,8 @@ #ifdef IS_UNPATCHED_SYSTEMD #include <systemd/sd-bus.h> -int sd_bus_message_append_cmdline(sd_bus_message *m, const char *signature, - char ***x) +int sd_bus_message_append_cmdline(sd_bus_message* m, const char* signature, + char*** x) { return 0; } |

