From 96e51f7c5933ca814d6d8fb910008535bff81e74 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Sun, 29 Jan 2017 04:32:20 -0500 Subject: [PATCH] clang-tidy remove redundant --- .clang-tidy | 323 +++++++++++++++++- src/drivers/gps/devices | 2 +- src/drivers/gps/gps.cpp | 2 - .../ekf_att_pos_estimator_main.cpp | 1 - .../mc_att_control/mc_att_control_main.cpp | 1 - src/modules/navigator/navigator_main.cpp | 1 - .../position_estimator_inav_main.cpp | 1 - src/modules/sdlog2/sdlog2.c | 1 - src/modules/systemlib/pwm_limit/pwm_limit.c | 2 - .../vtol_att_control_main.cpp | 1 - src/platforms/posix/drivers/gpssim/gpssim.cpp | 1 - .../posix/drivers/tonealrmsim/tone_alarm.cpp | 1 - src/platforms/posix/main.cpp | 8 +- 13 files changed, 322 insertions(+), 23 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 28d25ed517..6239b88fab 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,11 +1,322 @@ -Checks: '-*,readability-braces-around-statements, - modernize-use-nullptr, - modernize-redundant-void-arg' -WarningsAsErrors: 'readability-braces-around-statements, - modernize-use-nullptr, - modernize-redundant-void-arg' +Checks: 'clang-diagnostic-*,-*, + clang-analyzer-optin.performance.Padding, + clang-analyzer-unix.cstring.*, + clang-analyzer-unix.StdCLibraryFunctions, + misc-unused-raii, + misc-virtual-near-miss, + modernize-redundant-void-arg, + modernize-use-nullptr, + readability-braces-around-statements, + readability-delete-null-pointer, + readability-deleted-default, + readability-identifier-naming, + readability-redundant-control-flow, + readability-redundant-function-ptr-dereference, + readability-redundant-string-cstr, + readability-redundant-string-init, + ' +WarningsAsErrors: ' + misc-unused-raii, + misc-virtual-near-miss, + modernize-redundant-void-arg, + modernize-use-nullptr, + readability-braces-around-statements, + readability-delete-null-pointer, + readability-deleted-default, + readability-identifier-naming, + readability-redundant-control-flow, + readability-redundant-function-ptr-dereference, + readability-redundant-string-cstr, + readability-redundant-string-init, + ' HeaderFilterRegex: '*.h, *.hpp' AnalyzeTemporaryDtors: false CheckOptions: + - key: google-readability-braces-around-statements.ShortStatementLines + value: '1' + - key: google-readability-function-size.StatementThreshold + value: '800' + - key: google-readability-namespace-comments.ShortNamespaceLines + value: '10' + - key: google-readability-namespace-comments.SpacesBeforeComments + value: '2' + - key: modernize-loop-convert.MaxCopySize + value: '16' + - key: modernize-loop-convert.MinConfidence + value: reasonable + - key: modernize-loop-convert.NamingStyle + value: CamelCase + - key: modernize-pass-by-value.IncludeStyle + value: llvm + - key: modernize-replace-auto-ptr.IncludeStyle + value: llvm + - key: modernize-use-nullptr.NullMacros + value: 'NULL' - key: readability-braces-around-statements.ShortStatementLines value: '1' + - key: readability-identifier-naming.AbstractClassCase + value: aNy_CasE + - key: readability-identifier-naming.AbstractClassPrefix + value: '' + - key: readability-identifier-naming.AbstractClassSuffix + value: '' + - key: readability-identifier-naming.ClassCase + value: aNy_CasE + - key: readability-identifier-naming.ClassConstantCase + value: aNy_CasE + - key: readability-identifier-naming.ClassConstantPrefix + value: '' + - key: readability-identifier-naming.ClassConstantSuffix + value: '' + - key: readability-identifier-naming.ClassMemberCase + value: aNy_CasE + - key: readability-identifier-naming.ClassMemberPrefix + value: '' + - key: readability-identifier-naming.ClassMemberSuffix + value: '' + - key: readability-identifier-naming.ClassMethodCase + value: aNy_CasE + - key: readability-identifier-naming.ClassMethodPrefix + value: '' + - key: readability-identifier-naming.ClassMethodSuffix + value: '' + - key: readability-identifier-naming.ClassPrefix + value: '' + - key: readability-identifier-naming.ClassSuffix + value: '' + - key: readability-identifier-naming.ConstantCase + value: aNy_CasE + - key: readability-identifier-naming.ConstantMemberCase + value: aNy_CasE + - key: readability-identifier-naming.ConstantMemberPrefix + value: '' + - key: readability-identifier-naming.ConstantMemberSuffix + value: '' + - key: readability-identifier-naming.ConstantParameterCase + value: aNy_CasE + - key: readability-identifier-naming.ConstantParameterPrefix + value: '' + - key: readability-identifier-naming.ConstantParameterSuffix + value: '' + - key: readability-identifier-naming.ConstantPrefix + value: '' + - key: readability-identifier-naming.ConstantSuffix + value: '' + - key: readability-identifier-naming.ConstexprFunctionCase + value: aNy_CasE + - key: readability-identifier-naming.ConstexprFunctionPrefix + value: '' + - key: readability-identifier-naming.ConstexprFunctionSuffix + value: '' + - key: readability-identifier-naming.ConstexprMethodCase + value: aNy_CasE + - key: readability-identifier-naming.ConstexprMethodPrefix + value: '' + - key: readability-identifier-naming.ConstexprMethodSuffix + value: '' + - key: readability-identifier-naming.ConstexprVariableCase + value: aNy_CasE + - key: readability-identifier-naming.ConstexprVariablePrefix + value: '' + - key: readability-identifier-naming.ConstexprVariableSuffix + value: '' + - key: readability-identifier-naming.EnumCase + value: aNy_CasE + - key: readability-identifier-naming.EnumConstantCase + value: aNy_CasE + - key: readability-identifier-naming.EnumConstantPrefix + value: '' + - key: readability-identifier-naming.EnumConstantSuffix + value: '' + - key: readability-identifier-naming.EnumPrefix + value: '' + - key: readability-identifier-naming.EnumSuffix + value: '' + - key: readability-identifier-naming.FunctionCase + value: aNy_CasE + - key: readability-identifier-naming.FunctionPrefix + value: '' + - key: readability-identifier-naming.FunctionSuffix + value: '' + - key: readability-identifier-naming.GlobalConstantCase + value: aNy_CasE + - key: readability-identifier-naming.GlobalConstantPrefix + value: '' + - key: readability-identifier-naming.GlobalConstantSuffix + value: '' + - key: readability-identifier-naming.GlobalFunctionCase + value: aNy_CasE + - key: readability-identifier-naming.GlobalFunctionPrefix + value: '' + - key: readability-identifier-naming.GlobalFunctionSuffix + value: '' + - key: readability-identifier-naming.GlobalVariableCase + value: aNy_CasE + - key: readability-identifier-naming.GlobalVariablePrefix + value: '' + - key: readability-identifier-naming.GlobalVariableSuffix + value: '' + - key: readability-identifier-naming.IgnoreFailedSplit + value: '0' + - key: readability-identifier-naming.InlineNamespaceCase + value: aNy_CasE + - key: readability-identifier-naming.InlineNamespacePrefix + value: '' + - key: readability-identifier-naming.InlineNamespaceSuffix + value: '' + - key: readability-identifier-naming.LocalConstantCase + value: aNy_CasE + - key: readability-identifier-naming.LocalConstantPrefix + value: '' + - key: readability-identifier-naming.LocalConstantSuffix + value: '' + - key: readability-identifier-naming.LocalVariableCase + value: aNy_CasE + - key: readability-identifier-naming.LocalVariablePrefix + value: '' + - key: readability-identifier-naming.LocalVariableSuffix + value: '' + - key: readability-identifier-naming.MacroDefinitionCase + value: aNy_CasE + - key: readability-identifier-naming.MacroDefinitionPrefix + value: '' + - key: readability-identifier-naming.MacroDefinitionSuffix + value: '' + - key: readability-identifier-naming.MemberCase + value: aNy_CasE + - key: readability-identifier-naming.MemberPrefix + value: '' + - key: readability-identifier-naming.MemberSuffix + value: '' + - key: readability-identifier-naming.MethodCase + value: aNy_CasE + - key: readability-identifier-naming.MethodPrefix + value: '' + - key: readability-identifier-naming.MethodSuffix + value: '' + - key: readability-identifier-naming.NamespaceCase + value: aNy_CasE + - key: readability-identifier-naming.NamespacePrefix + value: '' + - key: readability-identifier-naming.NamespaceSuffix + value: '' + - key: readability-identifier-naming.ParameterCase + value: aNy_CasE + - key: readability-identifier-naming.ParameterPackCase + value: aNy_CasE + - key: readability-identifier-naming.ParameterPackPrefix + value: '' + - key: readability-identifier-naming.ParameterPackSuffix + value: '' + - key: readability-identifier-naming.ParameterPrefix + value: '' + - key: readability-identifier-naming.ParameterSuffix + value: '' + - key: readability-identifier-naming.PrivateMemberCase + value: aNy_CasE + - key: readability-identifier-naming.PrivateMemberPrefix + value: '' + - key: readability-identifier-naming.PrivateMemberSuffix + value: '' + - key: readability-identifier-naming.PrivateMethodCase + value: aNy_CasE + - key: readability-identifier-naming.PrivateMethodPrefix + value: '' + - key: readability-identifier-naming.PrivateMethodSuffix + value: '' + - key: readability-identifier-naming.ProtectedMemberCase + value: aNy_CasE + - key: readability-identifier-naming.ProtectedMemberPrefix + value: '' + - key: readability-identifier-naming.ProtectedMemberSuffix + value: '' + - key: readability-identifier-naming.ProtectedMethodCase + value: aNy_CasE + - key: readability-identifier-naming.ProtectedMethodPrefix + value: '' + - key: readability-identifier-naming.ProtectedMethodSuffix + value: '' + - key: readability-identifier-naming.PublicMemberCase + value: aNy_CasE + - key: readability-identifier-naming.PublicMemberPrefix + value: '' + - key: readability-identifier-naming.PublicMemberSuffix + value: '' + - key: readability-identifier-naming.PublicMethodCase + value: aNy_CasE + - key: readability-identifier-naming.PublicMethodPrefix + value: '' + - key: readability-identifier-naming.PublicMethodSuffix + value: '' + - key: readability-identifier-naming.StaticConstantCase + value: aNy_CasE + - key: readability-identifier-naming.StaticConstantPrefix + value: '' + - key: readability-identifier-naming.StaticConstantSuffix + value: '' + - key: readability-identifier-naming.StaticVariableCase + value: aNy_CasE + - key: readability-identifier-naming.StaticVariablePrefix + value: '' + - key: readability-identifier-naming.StaticVariableSuffix + value: '' + - key: readability-identifier-naming.StructCase + value: aNy_CasE + - key: readability-identifier-naming.StructPrefix + value: '' + - key: readability-identifier-naming.StructSuffix + value: '' + - key: readability-identifier-naming.TemplateParameterCase + value: aNy_CasE + - key: readability-identifier-naming.TemplateParameterPrefix + value: '' + - key: readability-identifier-naming.TemplateParameterSuffix + value: '' + - key: readability-identifier-naming.TemplateTemplateParameterCase + value: aNy_CasE + - key: readability-identifier-naming.TemplateTemplateParameterPrefix + value: '' + - key: readability-identifier-naming.TemplateTemplateParameterSuffix + value: '' + - key: readability-identifier-naming.TypeAliasCase + value: aNy_CasE + - key: readability-identifier-naming.TypeAliasPrefix + value: '' + - key: readability-identifier-naming.TypeAliasSuffix + value: '' + - key: readability-identifier-naming.TypeTemplateParameterCase + value: aNy_CasE + - key: readability-identifier-naming.TypeTemplateParameterPrefix + value: '' + - key: readability-identifier-naming.TypeTemplateParameterSuffix + value: '' + - key: readability-identifier-naming.TypedefCase + value: aNy_CasE + - key: readability-identifier-naming.TypedefPrefix + value: '' + - key: readability-identifier-naming.TypedefSuffix + value: '' + - key: readability-identifier-naming.UnionCase + value: aNy_CasE + - key: readability-identifier-naming.UnionPrefix + value: '' + - key: readability-identifier-naming.UnionSuffix + value: '' + - key: readability-identifier-naming.ValueTemplateParameterCase + value: aNy_CasE + - key: readability-identifier-naming.ValueTemplateParameterPrefix + value: '' + - key: readability-identifier-naming.ValueTemplateParameterSuffix + value: '' + - key: readability-identifier-naming.VariableCase + value: aNy_CasE + - key: readability-identifier-naming.VariablePrefix + value: '' + - key: readability-identifier-naming.VariableSuffix + value: '' + - key: readability-identifier-naming.VirtualMethodCase + value: aNy_CasE + - key: readability-identifier-naming.VirtualMethodPrefix + value: '' + - key: readability-identifier-naming.VirtualMethodSuffix + value: '' diff --git a/src/drivers/gps/devices b/src/drivers/gps/devices index 448f1e6577..61c7133372 160000 --- a/src/drivers/gps/devices +++ b/src/drivers/gps/devices @@ -1 +1 @@ -Subproject commit 448f1e657736a1e326194a0a79817ccf36644ef8 +Subproject commit 61c7133372737734207bda5b4531aa6ed5801084 diff --git a/src/drivers/gps/gps.cpp b/src/drivers/gps/gps.cpp index e6b72d797e..c6c4550143 100644 --- a/src/drivers/gps/gps.cpp +++ b/src/drivers/gps/gps.cpp @@ -1036,7 +1036,6 @@ void reset() { PX4_ERR("GPS reset not supported"); - return; } /** @@ -1056,7 +1055,6 @@ info() g_dev[1]->print_info(); } - return; } void print_usage() diff --git a/src/examples/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp b/src/examples/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp index 9f336740b8..3786d39363 100644 --- a/src/examples/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp +++ b/src/examples/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp @@ -740,7 +740,6 @@ void AttitudePositionEstimatorEKF::task_main() _task_running = false; _estimator_task = -1; - return; } void AttitudePositionEstimatorEKF::initReferencePosition(hrt_abstime timestamp, diff --git a/src/modules/mc_att_control/mc_att_control_main.cpp b/src/modules/mc_att_control/mc_att_control_main.cpp index a424827fca..3f85467123 100644 --- a/src/modules/mc_att_control/mc_att_control_main.cpp +++ b/src/modules/mc_att_control/mc_att_control_main.cpp @@ -1357,7 +1357,6 @@ MulticopterAttitudeControl::task_main() } _control_task = -1; - return; } int diff --git a/src/modules/navigator/navigator_main.cpp b/src/modules/navigator/navigator_main.cpp index 28b1db4d75..577f395b9c 100644 --- a/src/modules/navigator/navigator_main.cpp +++ b/src/modules/navigator/navigator_main.cpp @@ -695,7 +695,6 @@ Navigator::task_main() PX4_INFO("exiting"); _navigator_task = -1; - return; } int diff --git a/src/modules/position_estimator_inav/position_estimator_inav_main.cpp b/src/modules/position_estimator_inav/position_estimator_inav_main.cpp index a3fab5e5bf..29cc90447a 100644 --- a/src/modules/position_estimator_inav/position_estimator_inav_main.cpp +++ b/src/modules/position_estimator_inav/position_estimator_inav_main.cpp @@ -119,7 +119,6 @@ static void usage(const char *reason) } PX4_INFO("usage: position_estimator_inav {start|stop|status} [-v]\n"); - return; } /** diff --git a/src/modules/sdlog2/sdlog2.c b/src/modules/sdlog2/sdlog2.c index 346d1522c6..030b9646fc 100644 --- a/src/modules/sdlog2/sdlog2.c +++ b/src/modules/sdlog2/sdlog2.c @@ -493,7 +493,6 @@ int create_log_dir() /* dir exists already */ dir_number++; - continue; } if (dir_number >= MAX_NO_LOGFOLDER) { diff --git a/src/modules/systemlib/pwm_limit/pwm_limit.c b/src/modules/systemlib/pwm_limit/pwm_limit.c index 92eead22db..2c587541e3 100644 --- a/src/modules/systemlib/pwm_limit/pwm_limit.c +++ b/src/modules/systemlib/pwm_limit/pwm_limit.c @@ -52,7 +52,6 @@ void pwm_limit_init(pwm_limit_t *limit) { limit->state = PWM_LIMIT_STATE_INIT; limit->time_armed = 0; - return; } void pwm_limit_calc(const bool armed, const bool pre_armed, const unsigned num_channels, const uint16_t reverse_mask, @@ -225,5 +224,4 @@ void pwm_limit_calc(const bool armed, const bool pre_armed, const unsigned num_c break; } - return; } diff --git a/src/modules/vtol_att_control/vtol_att_control_main.cpp b/src/modules/vtol_att_control/vtol_att_control_main.cpp index d6e6baf0c3..552911145c 100644 --- a/src/modules/vtol_att_control/vtol_att_control_main.cpp +++ b/src/modules/vtol_att_control/vtol_att_control_main.cpp @@ -836,7 +836,6 @@ void VtolAttitudeControl::task_main() warnx("exit"); _control_task = -1; - return; } int diff --git a/src/platforms/posix/drivers/gpssim/gpssim.cpp b/src/platforms/posix/drivers/gpssim/gpssim.cpp index e0e87e786f..95b779a944 100644 --- a/src/platforms/posix/drivers/gpssim/gpssim.cpp +++ b/src/platforms/posix/drivers/gpssim/gpssim.cpp @@ -375,7 +375,6 @@ GPSSIM::task_main() /* tell the dtor that we are exiting */ _task = -1; - return; } diff --git a/src/platforms/posix/drivers/tonealrmsim/tone_alarm.cpp b/src/platforms/posix/drivers/tonealrmsim/tone_alarm.cpp index 07a7cb8c9b..d33409dba1 100644 --- a/src/platforms/posix/drivers/tonealrmsim/tone_alarm.cpp +++ b/src/platforms/posix/drivers/tonealrmsim/tone_alarm.cpp @@ -594,7 +594,6 @@ tune_end: _default_tune_number = 0; } - return; } int diff --git a/src/platforms/posix/main.cpp b/src/platforms/posix/main.cpp index bebecf9396..a18a6bc7e6 100644 --- a/src/platforms/posix/main.cpp +++ b/src/platforms/posix/main.cpp @@ -317,10 +317,10 @@ int main(int argc, char **argv) set_cpu_scaling(); int index = 1; - string commands_file = ""; + string commands_file; int positional_arg_count = 0; - string data_path = ""; - string node_name = ""; + string data_path; + string node_name; // parse arguments while (index < argc) { @@ -501,7 +501,7 @@ int main(int argc, char **argv) } if (!daemon_mode) { - string mystr = ""; + string mystr; string string_buffer[CMD_BUFF_SIZE]; int buf_ptr_write = 0; int buf_ptr_read = 0;