Apply a bunch of code fixes from sonarcloud. (#492)

This commit is contained in:
Brenden Matthews 2018-05-13 09:58:03 -04:00 committed by GitHub
parent 42e43435f4
commit e91b91d85a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 968 additions and 556 deletions

117
.clang-format Normal file
View File

@ -0,0 +1,117 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Delimiter: pb
Language: TextProto
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 8
UseTab: Never
...

View File

@ -4,4 +4,4 @@ root = true
end_of_line = lf
insert_final_newline = true
indent_style = space
intend_size = 2
indent_size = 2

View File

@ -7,7 +7,6 @@ matrix:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
packages:
- g++-8
- cmake
@ -24,7 +23,6 @@ matrix:
- libimlib2-dev
- libxinerama-dev
- gawk
- clang-6.0
sonarcloud:
organization: "brndnmtthws-github"
token:
@ -65,8 +63,6 @@ before_script:
- mkdir build && cd build
- cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
- cd ..
- cp build/compile_commands.json .
- ./bin/check-style.sh
- mkdir build-no-x11
- cd build-no-x11
- cmake -DBUILD_X11=OFF ..
@ -77,7 +73,7 @@ script:
- cd ../build-no-x11
- make -j4
- cd ..
- if [ "$CC" = "gcc-8" ] ; then sonar-scanner ; fi
- if [ "$CXX" = "clang++-6.0" ] ; then sonar-scanner ; fi
branches:
only:
- master

View File

@ -2,3 +2,4 @@ sonar.projectKey=conky
sonar.projectName=Conky
sonar.sources=src
sonar.cfamily.build-wrapper-output=build/bw-output
sonar.cpp.std=c++17

View File

@ -230,6 +230,7 @@ int update_apcupsd() {
freeaddrinfo(ai);
if (rp == nullptr) {
// no error reporting, the daemon is probably not running
close(sock);
break;
}
@ -241,6 +242,7 @@ int update_apcupsd() {
if (send(sock, &sz, sizeof(sz), 0) != sizeof(sz) ||
send(sock, "status", 6, 0) != 6) {
perror("send");
close(sock);
break;
}
@ -248,13 +250,12 @@ int update_apcupsd() {
// read the lines of output and put them into the info structure
//
if (fill_items(sock, &apc) == 0) {
close(sock);
break;
}
} while (0);
close(sock);
//
// "atomically" copy the data into working set
//

View File

@ -48,14 +48,14 @@
* different styles at some specific places... :)
*/
#include "darwin.h"
#include "conky.h" // for struct info
#include "darwin.h"
#include <AvailabilityMacros.h>
#include <cstdio>
#include <sys/mount.h> // statfs
#include <sys/sysctl.h>
#include <cstdio>
#include <mach/mach_host.h>
#include <mach/mach_init.h>
@ -65,12 +65,12 @@
#include <mach/mach.h> // update_total_processes
#include "top.h" // get_top_info
#include <dispatch/dispatch.h> // get_top_info
#include <libproc.h> // get_top_info
#include "top.h" // get_top_info
#include "net_stat.h" // update_net_stats
#include <ifaddrs.h> // update_net_stats
#include "net_stat.h" // update_net_stats
#include "darwin_sip.h" // sip status
@ -110,13 +110,9 @@ static conky::simple_config_setting<bool> top_cpu_separate("top_cpu_separate",
static int getsysctl(const char *name, void *ptr, size_t len) {
size_t nlen = len;
if (sysctlbyname(name, ptr, &nlen, nullptr, 0) == -1) {
return -1;
}
if (sysctlbyname(name, ptr, &nlen, nullptr, 0) == -1) { return -1; }
if (nlen != len && errno == ENOMEM) {
return -1;
}
if (nlen != len && errno == ENOMEM) { return -1; }
return 0;
}
@ -187,9 +183,7 @@ static void helper_update_threads_processes() {
processorSet, PROCESSOR_SET_LOAD_INFO,
reinterpret_cast<processor_set_info_t>(&loadInfo), &count);
if (err != KERN_SUCCESS) {
return;
}
if (err != KERN_SUCCESS) { return; }
info.procs = loadInfo.task_count;
info.threads = loadInfo.thread_count;
@ -303,8 +297,8 @@ static int helper_get_proc_list(struct kinfo_proc **p) {
static const int name[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0};
/* Call sysctl with a nullptr buffer to get proper length */
err = sysctl((int *)name, (sizeof(name) / sizeof(*name)) - 1, nullptr, &length,
nullptr, 0);
err = sysctl((int *)name, (sizeof(name) / sizeof(*name)) - 1, nullptr,
&length, nullptr, 0);
if (err != 0) {
perror(nullptr);
return (-1);
@ -405,9 +399,7 @@ int check_mount(struct text_object *obj) {
int num_mounts = 0;
struct statfs *mounts;
if (obj->data.s == nullptr) {
return 0;
}
if (obj->data.s == nullptr) { return 0; }
num_mounts = getmntinfo(&mounts, MNT_WAIT);
@ -417,9 +409,7 @@ int check_mount(struct text_object *obj) {
}
for (int i = 0; i < num_mounts; i++) {
if (strcmp(mounts[i].f_mntonname, obj->data.s) == 0) {
return 1;
}
if (strcmp(mounts[i].f_mntonname, obj->data.s) == 0) { return 1; }
}
return 0;
@ -509,7 +499,8 @@ static void update_pages_stolen(libtop_tsamp_t *tsamp) {
return;
}
if (-1 == sysctl(mib_other, mib_other_len, &other, &other_len, nullptr, 0)) {
if (-1 ==
sysctl(mib_other, mib_other_len, &other, &other_len, nullptr, 0)) {
return;
}
@ -541,9 +532,7 @@ static int libtop_tsamp_update_vm_stats(libtop_tsamp_t *tsamp) {
kr = host_statistics64(mach_host_self(), HOST_VM_INFO64,
reinterpret_cast<host_info64_t>(&tsamp->vm_stat),
&count);
if (kr != KERN_SUCCESS) {
return kr;
}
if (kr != KERN_SUCCESS) { return kr; }
if (tsamp->pages_stolen > 0) {
tsamp->vm_stat.wire_count += tsamp->pages_stolen;
@ -589,9 +578,7 @@ int update_meminfo() {
static libtop_tsamp_t *tsamp = nullptr;
if (tsamp == nullptr) {
tsamp = new libtop_tsamp_t;
if (tsamp == nullptr) {
return 0;
}
if (tsamp == nullptr) { return 0; }
memset(tsamp, 0, sizeof(libtop_tsamp_t));
tsamp->pagesize = page_size;
@ -606,9 +593,7 @@ int update_meminfo() {
* but first update pages stolen count
*/
update_pages_stolen(tsamp);
if (libtop_tsamp_update_vm_stats(tsamp) == KERN_FAILURE) {
return 0;
}
if (libtop_tsamp_update_vm_stats(tsamp) == KERN_FAILURE) { return 0; }
/*
* This is actually a tricky part.
@ -662,13 +647,9 @@ int update_net_stats() {
/* get delta */
delta = current_update_time - last_update_time;
if (delta <= 0.0001) {
return 0;
}
if (delta <= 0.0001) { return 0; }
if (getifaddrs(&ifap) < 0) {
return 0;
}
if (getifaddrs(&ifap) < 0) { return 0; }
for (ifa = ifap; ifa != nullptr; ifa = ifa->ifa_next) {
ns = get_net_stat((const char *)ifa->ifa_name, nullptr, nullptr);
@ -680,9 +661,7 @@ int update_net_stats() {
last_recv = ns->recv;
last_trans = ns->trans;
if (ifa->ifa_addr->sa_family != AF_LINK) {
continue;
}
if (ifa->ifa_addr->sa_family != AF_LINK) { continue; }
for (iftmp = ifa->ifa_next;
iftmp != nullptr && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
@ -749,9 +728,7 @@ int update_running_threads() {
proc_count = helper_get_proc_list(&p);
if (proc_count == -1) {
return 0;
}
if (proc_count == -1) { return 0; }
for (int i = 0; i < proc_count; i++) {
if ((p[i].kp_proc.p_stat & SRUN) != 0) {
@ -774,9 +751,7 @@ int update_running_threads() {
for (int i = 0; i < num_threads; i++) {
if (sizeof(pthi) ==
proc_pidinfo(pid, PROC_PIDTHREADINFO, i, &pthi, sizeof(pthi))) {
if (pthi.pth_run_state == TH_STATE_RUNNING) {
run_threads++;
}
if (pthi.pth_run_state == TH_STATE_RUNNING) { run_threads++; }
} else {
continue;
}
@ -791,7 +766,6 @@ int update_running_threads() {
int update_total_processes() {
helper_update_threads_processes();
return 0;
/*
* WARNING: You may stumble upon this implementation:
@ -837,9 +811,7 @@ int update_running_processes() {
proc_count = helper_get_proc_list(&p);
if (proc_count == -1) {
return 0;
}
if (proc_count == -1) { return 0; }
for (int i = 0; i < proc_count; i++) {
int state = p[i].kp_proc.p_stat;
@ -878,9 +850,7 @@ void get_cpu_count() {
*/
info.cpu_usage =
static_cast<float *>(malloc((info.cpu_count + 1) * sizeof(float)));
if (info.cpu_usage == nullptr) {
CRIT_ERR(nullptr, nullptr, "malloc");
}
if (info.cpu_usage == nullptr) { CRIT_ERR(nullptr, nullptr, "malloc"); }
}
}
@ -1075,9 +1045,7 @@ int get_entropy_poolsize(const unsigned int *val) {
*/
static void calc_cpu_usage_for_proc(struct process *proc, uint64_t total) {
float mul = 100.0;
if (top_cpu_separate.get(*state)) {
mul *= info.cpu_count;
}
if (top_cpu_separate.get(*state)) { mul *= info.cpu_count; }
proc->amount =
mul * (proc->user_time + proc->kernel_time) / static_cast<float>(total);
@ -1193,9 +1161,7 @@ static void get_top_info_for_kinfo_proc(struct kinfo_proc *p) {
/*
* wait until done
*/
while (!(calc_cpu_total_finished && calc_proc_total_finished)) {
;
}
while (!(calc_cpu_total_finished && calc_proc_total_finished)) { ; }
/* calc the amount(%) of CPU the process used */
calc_cpu_usage_for_proc(proc, t);
@ -1229,9 +1195,7 @@ void get_top_info() {
*/
proc_count = helper_get_proc_list(&p);
if (proc_count == -1) {
return;
}
if (proc_count == -1) { return; }
/*
* get top info for-each process
@ -1259,9 +1223,7 @@ void get_top_info() {
bool _csr_check(int aMask, bool aFlipflag) {
bool bit = (info.csr_config & aMask) != 0u;
if (aFlipflag) {
return !bit;
}
if (aFlipflag) { return !bit; }
return bit;
}
@ -1350,9 +1312,7 @@ void print_sip_status(struct text_object *obj, char *p, int p_max_size) {
/* conky window output */
(void)obj;
if (obj->data.s == nullptr) {
return;
}
if (obj->data.s == nullptr) { return; }
if (strlen(obj->data.s) == 0) {
snprintf(p, p_max_size, "%s",

View File

@ -82,13 +82,9 @@ static short cpu_setup = 0;
static int getsysctl(const char *name, void *ptr, size_t len) {
size_t nlen = len;
if (sysctlbyname(name, ptr, &nlen, nullptr, 0) == -1) {
return -1;
}
if (sysctlbyname(name, ptr, &nlen, nullptr, 0) == -1) { return -1; }
if (nlen != len && errno == ENOMEM) {
return -1;
}
if (nlen != len && errno == ENOMEM) { return -1; }
return 0;
}
@ -107,9 +103,7 @@ static int swapmode(unsigned long *retavail, unsigned long *retfree) {
#define CONVERT(v) ((quad_t)(v) * (pagesize / 1024))
n = kvm_getswapinfo(kd, swapary, 1, 0);
if (n < 0 || swapary[0].ksw_total == 0) {
return 0;
}
if (n < 0 || swapary[0].ksw_total == 0) { return 0; }
*retavail = CONVERT(swapary[0].ksw_total);
*retfree = CONVERT(swapary[0].ksw_total - swapary[0].ksw_used);
@ -147,9 +141,7 @@ int check_mount(struct text_object *obj) {
mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
for (i = mntsize - 1; i >= 0; i--) {
if (strcmp(mntbuf[i].f_mntonname, obj->data.s) == 0) {
return 1;
}
if (strcmp(mntbuf[i].f_mntonname, obj->data.s) == 0) { return 1; }
}
return 0;
@ -200,13 +192,9 @@ int update_net_stats(void) {
/* get delta */
delta = current_update_time - last_update_time;
if (delta <= 0.0001) {
return 0;
}
if (delta <= 0.0001) { return 0; }
if (getifaddrs(&ifap) < 0) {
return 0;
}
if (getifaddrs(&ifap) < 0) { return 0; }
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
ns = get_net_stat((const char *)ifa->ifa_name, nullptr, NULL);
@ -218,9 +206,7 @@ int update_net_stats(void) {
last_recv = ns->recv;
last_trans = ns->trans;
if (ifa->ifa_addr->sa_family != AF_LINK) {
continue;
}
if (ifa->ifa_addr->sa_family != AF_LINK) { continue; }
for (iftmp = ifa->ifa_next;
iftmp != nullptr && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
@ -269,7 +255,6 @@ int update_total_processes(void) {
kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
info.procs = n_processes;
return 0;
}
int update_running_processes(void) {
@ -280,9 +265,7 @@ int update_running_processes(void) {
std::lock_guard<std::mutex> guard(kvm_proc_mutex);
p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
for (i = 0; i < n_processes; i++) {
if (p[i].ki_stat == SRUN) {
cnt++;
}
if (p[i].ki_stat == SRUN) { cnt++; }
}
info.run_procs = cnt;
@ -301,9 +284,7 @@ void get_cpu_count(void) {
}
info.cpu_usage = (float *)malloc((info.cpu_count + 1) * sizeof(float));
if (info.cpu_usage == nullptr) {
CRIT_ERR(nullptr, NULL, "malloc");
}
if (info.cpu_usage == nullptr) { CRIT_ERR(nullptr, NULL, "malloc"); }
}
struct cpu_info {
@ -510,9 +491,7 @@ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size,
(void)adapter; // only linux uses this
if (!p_client_buffer || client_buffer_size <= 0) {
return;
}
if (!p_client_buffer || client_buffer_size <= 0) { return; }
if (GETSYSCTL("hw.acpi.acline", state)) {
fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
@ -545,9 +524,7 @@ char get_freq(char *p_client_buffer, size_t client_buffer_size,
}
freq_sysctl = (char *)calloc(16, sizeof(char));
if (freq_sysctl == nullptr) {
exit(-1);
}
if (freq_sysctl == nullptr) { exit(-1); }
snprintf(freq_sysctl, 16, "dev.cpu.%d.freq", (cpu - 1));
@ -639,8 +616,8 @@ int update_diskio(void) {
devs_count = statinfo_cur.dinfo->numdevs;
if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
&select_generation, statinfo_cur.dinfo->generation,
statinfo_cur.dinfo->devices, devs_count, nullptr, 0, NULL,
0, DS_SELECT_ONLY, MAXSHOWDEVS, 1) >= 0) {
statinfo_cur.dinfo->devices, devs_count, nullptr, 0,
NULL, 0, DS_SELECT_ONLY, MAXSHOWDEVS, 1) >= 0) {
for (dn = 0; dn < devs_count; dn++) {
int di;
struct devstat *dev;

View File

@ -27,13 +27,13 @@
*
*/
#include "fs.h"
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#include <cctype>
#include <cerrno>
#include "conky.h"
#include "fs.h"
#include "logging.h"
#include "specials.h"
#include "text_object.h"
@ -76,14 +76,10 @@ int update_fs_stats() {
unsigned i;
static double last_fs_update = 0.0;
if (current_update_time - last_fs_update < 13) {
return 0;
}
if (current_update_time - last_fs_update < 13) { return 0; }
for (i = 0; i < MAX_FS_STATS; ++i) {
if (fs_stats[i].set != 0) {
update_fs_stat(&fs_stats[i]);
}
if (fs_stats[i].set != 0) { update_fs_stat(&fs_stats[i]); }
}
last_fs_update = current_update_time;
return 0;
@ -187,13 +183,16 @@ void get_fs_type(const char *path, char *result) {
if (!match) break;
fseek(mtab, 0, SEEK_SET);
slash = strrchr(search_path, '/');
if (slash == nullptr) CRIT_ERR(NULL, NULL, "invalid path '%s'", path);
if (strlen(slash) == 1) /* trailing slash */
*(slash) = '\0';
else if (strlen(slash) > 1)
*(slash + 1) = '\0';
else
CRIT_ERR(nullptr, NULL, "found a crack in the matrix!");
if (slash == nullptr) {
CRIT_ERR(NULL, NULL, "invalid path '%s'", path);
} else {
if (strlen(slash) == 1) /* trailing slash */
*(slash) = '\0';
else if (strlen(slash) > 1)
*(slash + 1) = '\0';
else
CRIT_ERR(nullptr, NULL, "found a crack in the matrix!");
}
} while (strlen(search_path) > 0);
free(search_path);
@ -211,12 +210,8 @@ void get_fs_type(const char *path, char *result) {
void init_fs_bar(struct text_object *obj, const char *arg) {
arg = scan_bar(obj, arg, 1);
if (arg != nullptr) {
while (isspace(*arg) != 0) {
arg++;
}
if (*arg == '\0') {
arg = "/";
}
while (isspace(*arg) != 0) { arg++; }
if (*arg == '\0') { arg = "/"; }
} else {
arg = "/";
}
@ -270,7 +265,5 @@ HUMAN_PRINT_FS_GENERATOR(used, fs->size - fs->free)
void print_fs_type(struct text_object *obj, char *p, int p_max_size) {
auto *fs = static_cast<struct fs_stat *>(obj->data.opaque);
if (fs != nullptr) {
snprintf(p, p_max_size, "%s", fs->type);
}
if (fs != nullptr) { snprintf(p, p_max_size, "%s", fs->type); }
}

View File

@ -77,7 +77,6 @@ int update_net_stats() {
int update_total_processes() {
// TODO
return 1;
}
int update_running_processes() {
@ -96,9 +95,7 @@ void get_cpu_count(void) {
info.cpu_count = si.cpu_count;
info.cpu_usage = (float *)malloc((info.cpu_count + 1) * sizeof(float));
if (info.cpu_usage == nullptr) {
CRIT_ERR(nullptr, NULL, "malloc");
}
if (info.cpu_usage == nullptr) { CRIT_ERR(nullptr, NULL, "malloc"); }
}
int update_cpu_usage() {
@ -118,18 +115,14 @@ int update_cpu_usage() {
if (!prev_cpuinfo) {
prev_cpuinfo = (cpu_info *)malloc(malloc_cpu_size);
if (prev_cpuinfo == nullptr) {
CRIT_ERR(nullptr, NULL, "malloc");
}
if (prev_cpuinfo == nullptr) { CRIT_ERR(nullptr, NULL, "malloc"); }
memset(prev_cpuinfo, 0, malloc_cpu_size);
}
cpuinfo = (cpu_info *)malloc(malloc_cpu_size);
memset(cpuinfo, 0, malloc_cpu_size);
if (cpuinfo == nullptr) {
CRIT_ERR(nullptr, NULL, "malloc");
}
if (cpuinfo == nullptr) { CRIT_ERR(nullptr, NULL, "malloc"); }
now = system_time();
if (get_cpu_info(0, info.cpu_count, &cpuinfo[1]) == B_OK) {
@ -183,9 +176,7 @@ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size,
const char *adapter) {
(void)adapter; // only linux uses this
if (!p_client_buffer || client_buffer_size <= 0) {
return;
}
if (!p_client_buffer || client_buffer_size <= 0) { return; }
/* not implemented */
memset(p_client_buffer, 0, client_buffer_size);
@ -193,9 +184,7 @@ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size,
/* char *get_acpi_fan() */
void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size) {
if (!p_client_buffer || client_buffer_size <= 0) {
return;
}
if (!p_client_buffer || client_buffer_size <= 0) { return; }
/* not implemented */
memset(p_client_buffer, 0, client_buffer_size);

View File

@ -33,16 +33,16 @@
*
*/
#include "libmpdclient.h"
#include "conky.h"
#include "libmpdclient.h"
#include <cctype>
#include <cerrno>
#include <climits>
#include <fcntl.h>
#include <sys/param.h>
#include <sys/types.h>
#include <unistd.h>
#include <cctype>
#include <cerrno>
#include <climits>
#ifdef WIN32
#include <winsock.h>
@ -60,7 +60,7 @@
#endif
#ifndef SOCK_CLOEXEC
# define SOCK_CLOEXEC O_CLOEXEC
#define SOCK_CLOEXEC O_CLOEXEC
#endif /* SOCK_CLOEXEC */
/* (bits + 1) / 3 (plus the sign character) */
@ -166,9 +166,7 @@ static int mpd_connect(mpd_Connection *connection, const char *host, int port,
struct addrinfo *res = nullptr;
struct addrinfo *addrinfo = nullptr;
if (*host == '/') {
return uds_connect(connection, host, timeout);
}
if (*host == '/') { return uds_connect(connection, host, timeout); }
/* Setup hints */
hints.ai_flags = AI_ADDRCONFIG;
@ -193,9 +191,7 @@ static int mpd_connect(mpd_Connection *connection, const char *host, int port,
for (res = addrinfo; res != nullptr; res = res->ai_next) {
/* create socket */
if (connection->sock > -1) {
closesocket(connection->sock);
}
if (connection->sock > -1) { closesocket(connection->sock); }
connection->sock =
socket(res->ai_family, SOCK_STREAM | SOCK_CLOEXEC, res->ai_protocol);
if (connection->sock < 0) {
@ -278,9 +274,7 @@ static int mpd_connect(mpd_Connection *connection, const char *host, int port,
break;
}
if (connection->sock > -1) {
closesocket(connection->sock);
}
if (connection->sock > -1) { closesocket(connection->sock); }
if ((connection->sock = socket(dest->sa_family, SOCK_STREAM, 0)) < 0) {
strcpy(connection->errorStr, "problems creating socket");
connection->error = MPD_ERROR_SYSTEM;
@ -318,9 +312,7 @@ static char *mpd_sanitizeArg(const char *arg) {
c = arg;
rc = ret;
for (i = strlen(arg) + 1; i != 0; --i) {
if (*c == '"' || *c == '\\') {
*rc++ = '\\';
}
if (*c == '"' || *c == '\\') { *rc++ = '\\'; }
*(rc++) = *(c++);
}
@ -367,9 +359,7 @@ static int mpd_parseWelcome(mpd_Connection *connection, const char *host,
tmp = &output[strlen(MPD_WELCOME_MESSAGE)];
for (i = 0; i < 3; i++) {
if (tmp != nullptr) {
connection->version[i] = strtol(tmp, &test, 10);
}
if (tmp != nullptr) { connection->version[i] = strtol(tmp, &test, 10); }
if ((tmp == nullptr) || (test[0] != '.' && test[0] != '\0')) {
snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
@ -406,13 +396,9 @@ mpd_Connection *mpd_newConnection(const char *host, int port, float timeout) {
connection->returnElement = nullptr;
connection->request = nullptr;
if (winsock_dll_error(connection)) {
return connection;
}
if (winsock_dll_error(connection)) { return connection; }
if (mpd_connect(connection, host, port, timeout) < 0) {
return connection;
}
if (mpd_connect(connection, host, port, timeout) < 0) { return connection; }
while ((rt = strstr(connection->buffer, "\n")) == nullptr) {
tv.tv_sec = connection->timeout.tv_sec;
@ -435,9 +421,7 @@ mpd_Connection *mpd_newConnection(const char *host, int port, float timeout) {
connection->buflen += readed;
connection->buffer[connection->buflen] = '\0';
} else if (err < 0) {
if (SELECT_ERRNO_IGNORE) {
continue;
}
if (SELECT_ERRNO_IGNORE) { continue; }
snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
"problems connecting to \"%s\" on port %i", host, port);
connection->error = MPD_ERROR_CONNPORT;
@ -502,26 +486,21 @@ static void mpd_executeCommand(mpd_Connection *connection,
tv.tv_sec = connection->timeout.tv_sec;
tv.tv_usec = connection->timeout.tv_usec;
while (((ret = static_cast<int>(select(connection->sock + 1, nullptr, &fds,
nullptr, &tv) == 1)) != 0) ||
(ret == -1 && SELECT_ERRNO_IGNORE)) {
do {
ret = static_cast<int>(
select(connection->sock + 1, nullptr, &fds, nullptr, &tv));
if (ret != 1 && !SELECT_ERRNO_IGNORE) { break; }
ret = send(connection->sock, commandPtr, commandLen, MSG_DONTWAIT);
if (ret <= 0) {
if (SENDRECV_ERRNO_IGNORE) {
continue;
}
if (SENDRECV_ERRNO_IGNORE) { continue; }
snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
"problems giving command \"%s\"", command);
connection->error = MPD_ERROR_SENDING;
return;
}
commandPtr += ret;
commandLen -= ret;
if (commandLen <= 0) {
break;
}
}
commandPtr += ret;
commandLen -= ret;
} while (commandLen > 0);
if (commandLen > 0) {
perror("");
@ -588,9 +567,7 @@ static void mpd_getNextReturnElement(mpd_Connection *connection) {
nullptr, &tv) == 1)) != 0) {
readed = recv(connection->sock, connection->buffer + connection->buflen,
MPD_BUFFER_MAX_LENGTH - connection->buflen, MSG_DONTWAIT);
if (readed < 0 && SENDRECV_ERRNO_IGNORE) {
continue;
}
if (readed < 0 && SENDRECV_ERRNO_IGNORE) { continue; }
if (readed <= 0) {
strcpy(connection->errorStr, "connection closed");
connection->error = MPD_ERROR_CONNCLOSED;
@ -600,8 +577,6 @@ static void mpd_getNextReturnElement(mpd_Connection *connection) {
}
connection->buflen += readed;
connection->buffer[connection->buflen] = '\0';
} else if (err < 0 && SELECT_ERRNO_IGNORE) {
continue;
} else {
strcpy(connection->errorStr, "connection timeout");
connection->error = MPD_ERROR_TIMEOUT;
@ -650,26 +625,18 @@ static void mpd_getNextReturnElement(mpd_Connection *connection) {
connection->doneListOk = 0;
needle = strchr(output, '[');
if (needle == nullptr) {
return;
}
if (needle == nullptr) { return; }
val = strtol(needle + 1, &test, 10);
if (*test != '@') {
return;
}
if (*test != '@') { return; }
connection->errorCode = val;
val = strtol(test + 1, &test, 10);
if (*test != ']') {
return;
}
if (*test != ']') { return; }
connection->errorAt = val;
return;
}
tok = strchr(output, ':');
if (tok == nullptr) {
return;
}
if (tok == nullptr) { return; }
pos = tok - output;
value = ++tok;
name = output;
@ -686,9 +653,7 @@ static void mpd_getNextReturnElement(mpd_Connection *connection) {
void mpd_finishCommand(mpd_Connection *connection) {
while ((connection != nullptr) && (connection->doneProcessing == 0)) {
if (connection->doneListOk != 0) {
connection->doneListOk = 0;
}
if (connection->doneListOk != 0) { connection->doneListOk = 0; }
mpd_getNextReturnElement(connection);
}
}
@ -702,9 +667,7 @@ static void mpd_finishListOkCommand(mpd_Connection *connection) {
int mpd_nextListOkCommand(mpd_Connection *connection) {
mpd_finishListOkCommand(connection);
if (connection->doneProcessing == 0) {
connection->doneListOk = 0;
}
if (connection->doneProcessing == 0) { connection->doneListOk = 0; }
if (connection->listOks == 0 || (connection->doneProcessing != 0)) {
return -1;
}
@ -719,9 +682,9 @@ mpd_Status *mpd_getStatus(mpd_Connection *connection) {
mpd_Status *status;
/* mpd_executeCommand(connection, "status\n");
if (connection->error) {
return nullptr;
} */
if (connection->error) {
return nullptr;
} */
if ((connection->doneProcessing != 0) ||
((connection->listOks != 0) && (connection->doneListOk != 0))) {
@ -846,9 +809,9 @@ mpd_Stats *mpd_getStats(mpd_Connection *connection) {
mpd_Stats *stats;
/* mpd_executeCommand(connection, "stats\n");
if (connection->error) {
return nullptr;
} */
if (connection->error) {
return nullptr;
} */
if ((connection->doneProcessing != 0) ||
((connection->listOks != 0) && (connection->doneListOk != 0))) {
@ -921,9 +884,7 @@ mpd_SearchStats *mpd_getSearchStats(mpd_Connection *connection) {
mpd_getNextReturnElement(connection);
}
if (connection->error != 0) {
return nullptr;
}
if (connection->error != 0) { return nullptr; }
stats = static_cast<mpd_SearchStats *>(malloc(sizeof(mpd_SearchStats)));
stats->numberOfSongs = 0;
@ -1196,18 +1157,10 @@ mpd_InfoEntity *mpd_getNextInfoEntity(mpd_Connection *connection) {
while (connection->returnElement != nullptr) {
mpd_ReturnElement *re = connection->returnElement;
if (strcmp(re->name, "file") == 0) {
return entity;
}
if (strcmp(re->name, "directory") == 0) {
return entity;
}
if (strcmp(re->name, "playlist") == 0) {
return entity;
}
if (strcmp(re->name, "cpos") == 0) {
return entity;
}
if (strcmp(re->name, "file") == 0) { return entity; }
if (strcmp(re->name, "directory") == 0) { return entity; }
if (strcmp(re->name, "playlist") == 0) { return entity; }
if (strcmp(re->name, "cpos") == 0) { return entity; }
if (entity->type == MPD_INFO_ENTITY_TYPE_SONG &&
(strlen(re->value) != 0u)) {
@ -1757,9 +1710,7 @@ mpd_OutputEntity *mpd_getNextOutput(mpd_Connection *connection) {
return nullptr;
}
if (connection->error != 0) {
return nullptr;
}
if (connection->error != 0) { return nullptr; }
output = static_cast<mpd_OutputEntity *>(malloc(sizeof(mpd_OutputEntity)));
output->id = -10;
@ -1774,9 +1725,7 @@ mpd_OutputEntity *mpd_getNextOutput(mpd_Connection *connection) {
mpd_ReturnElement *re = connection->returnElement;
if (strcmp(re->name, "outputid") == 0) {
if (output != nullptr && output->id >= 0) {
return output;
}
if (output != nullptr && output->id >= 0) { return output; }
output->id = atoi(re->value);
} else if (strcmp(re->name, "outputname") == 0) {
output->name = strndup(re->value, text_buffer_size.get(*state));

View File

@ -24,7 +24,6 @@
*
*/
#include "linux.h"
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
@ -35,6 +34,7 @@
#include "common.h"
#include "conky.h"
#include "diskio.h"
#include "linux.h"
#include "logging.h"
#include "net_stat.h"
#include "proc.h"
@ -170,14 +170,10 @@ int update_meminfo(void) {
info.swapfree = info.swapmax = info.bufmem = info.buffers = info.cached =
info.memfree = info.memeasyfree = 0;
if (!(meminfo_fp = open_file("/proc/meminfo", &rep))) {
return 0;
}
if (!(meminfo_fp = open_file("/proc/meminfo", &rep))) { return 0; }
while (!feof(meminfo_fp)) {
if (fgets(buf, 255, meminfo_fp) == nullptr) {
break;
}
if (fgets(buf, 255, meminfo_fp) == nullptr) { break; }
if (strncmp(buf, "MemTotal:", 9) == 0) {
sscanf(buf, "%*s %llu", &info.memmax);
@ -276,9 +272,7 @@ static struct {
}
void update_gateway_info_failure(const char *reason) {
if (reason != nullptr) {
perror(reason);
}
if (reason != nullptr) { perror(reason); }
// 2 pointers to 1 location causes a crash when we try to free them both
gw_info.iface = strndup("failed", text_buffer_size.get(*state));
gw_info.ip = strndup("failed", text_buffer_size.get(*state));
@ -385,9 +379,7 @@ int update_net_stats(void) {
/* get delta */
delta = current_update_time - last_update_time;
if (delta <= 0.0001) {
return 0;
}
if (delta <= 0.0001) { return 0; }
/* open file /proc/net/dev. If not something went wrong, clear all
* network statistics */
@ -398,8 +390,10 @@ int update_net_stats(void) {
/* ignore first two header lines in file /proc/net/dev. If somethings
* goes wrong, e.g. end of file reached, quit.
* (Why isn't clear_net_stats called for this case ??? */
if (!fgets(buf, 255, net_dev_fp) || /* garbage */
!fgets(buf, 255, net_dev_fp)) { /* garbage (field names) */
char *one = fgets(buf, 255, net_dev_fp);
char *two = fgets(buf, 255, net_dev_fp);
if (!one || /* garbage */
!two) { /* garbage (field names) */
fclose(net_dev_fp);
return 0;
}
@ -412,25 +406,17 @@ int update_net_stats(void) {
long long r, t, last_recv, last_trans;
/* quit only after all non-header lines from /proc/net/dev parsed */
if (fgets(buf, 255, net_dev_fp) == nullptr) {
break;
}
if (fgets(buf, 255, net_dev_fp) == nullptr) { break; }
p = buf;
/* change char * p to first non-space character, which is the beginning
* of the interface name */
while (*p != '\0' && isspace((int)*p)) {
p++;
}
while (*p != '\0' && isspace((int)*p)) { p++; }
s = p;
/* increment p until the end of the interface name has been reached */
while (*p != '\0' && *p != ':') {
p++;
}
if (*p == '\0') {
continue;
}
while (*p != '\0' && *p != ':') { p++; }
if (*p == '\0') { continue; }
/* replace ':' with '\0' in output of /proc/net/dev */
*p = '\0';
p++;
@ -580,9 +566,7 @@ int update_net_stats(void) {
}
// get ap mac
if (winfo->has_ap_addr) {
iw_sawap_ntop(&winfo->ap_addr, ns->ap);
}
if (winfo->has_ap_addr) { iw_sawap_ntop(&winfo->ap_addr, ns->ap); }
// get essid
if (winfo->b.has_essid) {
@ -682,21 +666,15 @@ int update_total_processes(void) {
char ignore2;
info.procs = 0;
if (!(dir = opendir("/proc"))) {
return 0;
}
while ((entry = readdir(dir))) {
if (!entry) {
/* Problem reading list of processes */
closedir(dir);
info.procs = 0;
return 0;
}
if (sscanf(entry->d_name, "%d%c", &ignore1, &ignore2) == 1) {
info.procs++;
dir = opendir("/proc");
if (dir) {
while ((entry = readdir(dir))) {
if (sscanf(entry->d_name, "%d%c", &ignore1, &ignore2) == 1) {
info.procs++;
}
}
closedir(dir);
}
closedir(dir);
return 0;
}
@ -783,9 +761,7 @@ void get_cpu_count(void) {
int subtoken1 = -1;
int subtoken2 = -1;
if (info.cpu_usage) {
return;
}
if (info.cpu_usage) { return; }
if (!(stat_fp = open_file("/sys/devices/system/cpu/present", &rep))) {
return;
@ -794,9 +770,7 @@ void get_cpu_count(void) {
info.cpu_count = 0;
while (!feof(stat_fp)) {
if (fgets(buf, 255, stat_fp) == nullptr) {
break;
}
if (fgets(buf, 255, stat_fp) == nullptr) { break; }
// Do some parsing here to handle skipped cpu numbers. For example,
// for an AMD FX(tm)-6350 Six-Core Processor /sys/.../present reports
@ -884,9 +858,7 @@ int update_stat(void) {
idx = 0;
while (!feof(stat_fp)) {
if (fgets(buf, 255, stat_fp) == nullptr) {
break;
}
if (fgets(buf, 255, stat_fp) == nullptr) { break; }
if (strncmp(buf, "procs_running ", 14) == 0) {
sscanf(buf, "%*s %hu", &info.run_threads);
@ -897,9 +869,7 @@ int update_stat(void) {
} else {
idx = 0;
}
if (idx > info.cpu_count) {
continue;
}
if (idx > info.cpu_count) { continue; }
sscanf(buf, stat_template, &(cpu[idx].cpu_user), &(cpu[idx].cpu_nice),
&(cpu[idx].cpu_system), &(cpu[idx].cpu_idle),
&(cpu[idx].cpu_iowait), &(cpu[idx].cpu_irq),
@ -915,9 +885,7 @@ int update_stat(void) {
delta = current_update_time - last_update_time;
if (delta <= 0.001) {
break;
}
if (delta <= 0.001) { break; }
cur_total = (float)(cpu[idx].cpu_total - cpu[idx].cpu_last_total);
if (cur_total == 0.0) {
@ -933,9 +901,7 @@ int update_stat(void) {
#ifdef HAVE_OPENMP
#pragma omp parallel for reduction(+ : curtmp) schedule(dynamic, 10)
#endif /* HAVE_OPENMP */
for (i = 0; i < samples; i++) {
curtmp = curtmp + cpu[idx].cpu_val[i];
}
for (i = 0; i < samples; i++) { curtmp = curtmp + cpu[idx].cpu_val[i]; }
info.cpu_usage[idx] = curtmp / samples;
cpu[idx].cpu_last_total = cpu[idx].cpu_total;
@ -1014,9 +980,7 @@ int update_load_average(void) {
/***********************************************************/
static int no_dots(const struct dirent *d) {
if (d->d_name[0] == '.') {
return 0;
}
if (d->d_name[0] == '.') { return 0; }
return 1;
}
@ -1028,15 +992,11 @@ static int get_first_file_in_a_directory(const char *dir, char *s, int *rep) {
if (n < 0) {
if (!rep || !*rep) {
NORM_ERR("scandir for %s: %s", dir, strerror(errno));
if (rep) {
*rep = 1;
}
if (rep) { *rep = 1; }
}
return 0;
} else {
if (n == 0) {
return 0;
}
if (n == 0) { return 0; }
strncpy(s, namelist[0]->d_name, 255);
s[255] = '\0';
@ -1044,9 +1004,7 @@ static int get_first_file_in_a_directory(const char *dir, char *s, int *rep) {
#ifdef HAVE_OPENMP
#pragma omp parallel for schedule(dynamic, 10)
#endif /* HAVE_OPENMP */
for (i = 0; i < n; i++) {
free(namelist[i]);
}
for (i = 0; i < n; i++) { free(namelist[i]); }
free(namelist);
return 1;
@ -1066,9 +1024,7 @@ static int open_sysfs_sensor(const char *dir, const char *dev, const char *type,
if (dev == nullptr || strcmp(dev, "*") == 0) {
static int rep = 0;
if (!get_first_file_in_a_directory(dir, buf, &rep)) {
return -1;
}
if (!get_first_file_in_a_directory(dir, buf, &rep)) { return -1; }
dev = buf;
}
@ -1119,9 +1075,7 @@ static int open_sysfs_sensor(const char *dir, const char *dev, const char *type,
*divisor = 0;
}
/* fan does not use *_div as a read divisor */
if (strcmp("fan", type) == 0) {
return fd;
}
if (strcmp("fan", type) == 0) { return fd; }
/* test if *_div file exist, open it and use it as divisor */
if (strcmp(type, "tempf") == 0) {
@ -1154,9 +1108,7 @@ static int open_sysfs_sensor(const char *dir, const char *dev, const char *type,
static double get_sysfs_info(int *fd, int divisor, char *devtype, char *type) {
int val = 0;
if (*fd <= 0) {
return 0;
}
if (*fd <= 0) { return 0; }
lseek(*fd, 0, SEEK_SET);
@ -1178,9 +1130,7 @@ static double get_sysfs_info(int *fd, int divisor, char *devtype, char *type) {
close(*fd);
/* open file */
*fd = open(devtype, O_RDONLY);
if (*fd < 0) {
NORM_ERR("can't open '%s': %s", devtype, strerror(errno));
}
if (*fd < 0) { NORM_ERR("can't open '%s': %s", devtype, strerror(errno)); }
/* My dirty hack for computing CPU value
* Filedil, from forums.gentoo.org */
@ -1425,9 +1375,6 @@ static char get_voltage(char *p_client_buffer, size_t client_buffer_size,
fprintf(stderr, PACKAGE_NAME ": Failed to access '%s' at ",
current_freq_file);
perror("get_voltage()");
if (f) {
fclose(f);
}
return 0;
}
@ -1441,22 +1388,15 @@ static char get_voltage(char *p_client_buffer, size_t client_buffer_size,
while (!feof(f)) {
char line[256];
if (fgets(line, 255, f) == nullptr) {
break;
}
if (fgets(line, 255, f) == nullptr) { break; }
sscanf(line, "%d %d", &freq_comp, &voltage);
if (freq_comp == freq) {
break;
}
if (freq_comp == freq) { break; }
}
fclose(f);
} else {
fprintf(stderr, PACKAGE_NAME ": Failed to access '%s' at ",
current_freq_file);
perror("get_voltage()");
if (f) {
fclose(f);
}
return 0;
}
snprintf(p_client_buffer, client_buffer_size, p_format,
@ -1466,16 +1406,12 @@ static char get_voltage(char *p_client_buffer, size_t client_buffer_size,
void print_voltage_mv(struct text_object *obj, char *p, int p_max_size) {
static int ok = 1;
if (ok) {
ok = get_voltage(p, p_max_size, "%.0f", 1, obj->data.i);
}
if (ok) { ok = get_voltage(p, p_max_size, "%.0f", 1, obj->data.i); }
}
void print_voltage_v(struct text_object *obj, char *p, int p_max_size) {
static int ok = 1;
if (ok) {
ok = get_voltage(p, p_max_size, "%'.3f", 1000, obj->data.i);
}
if (ok) { ok = get_voltage(p, p_max_size, "%'.3f", 1000, obj->data.i); }
}
#define ACPI_FAN_DIR "/proc/acpi/fan/"
@ -1486,9 +1422,7 @@ void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size) {
char buf2[256];
FILE *fp;
if (!p_client_buffer || client_buffer_size <= 0) {
return;
}
if (!p_client_buffer || client_buffer_size <= 0) { return; }
/* yeah, slow... :/ */
if (!get_first_file_in_a_directory(ACPI_FAN_DIR, buf, &rep)) {
@ -1540,9 +1474,7 @@ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size,
struct stat sb;
FILE *fp;
if (!p_client_buffer || client_buffer_size <= 0) {
return;
}
if (!p_client_buffer || client_buffer_size <= 0) { return; }
if (adapter)
snprintf(buf2, sizeof(buf2), "%s/%s/uevent", SYSFS_AC_ADAPTER_DIR, adapter);
@ -1620,9 +1552,7 @@ int open_acpi_temperature(const char *name) {
}
fd = open(path, O_RDONLY);
if (fd < 0) {
NORM_ERR("can't open '%s': %s", path, strerror(errno));
}
if (fd < 0) { NORM_ERR("can't open '%s': %s", path, strerror(errno)); }
return fd;
}
@ -1635,9 +1565,7 @@ static double last_acpi_temp_time;
#define MAXTHERMZONELEN 6
double get_acpi_temperature(int fd) {
if (fd <= 0) {
return 0;
}
if (fd <= 0) { return 0; }
/* don't update acpi temperature too often */
if (current_update_time - last_acpi_temp_time < 11.32) {
@ -1766,15 +1694,11 @@ static double last_battery_perct_time[MAX_BATTERY_COUNT];
void init_batteries(void) {
int idx;
if (batteries_initialized) {
return;
}
if (batteries_initialized) { return; }
#ifdef HAVE_OPENMP
#pragma omp parallel for schedule(dynamic, 10)
#endif /* HAVE_OPENMP */
for (idx = 0; idx < MAX_BATTERY_COUNT; idx++) {
batteries[idx][0] = '\0';
}
for (idx = 0; idx < MAX_BATTERY_COUNT; idx++) { batteries[idx][0] = '\0'; }
batteries_initialized = 1;
}
@ -1782,15 +1706,11 @@ int get_battery_idx(const char *bat) {
int idx;
for (idx = 0; idx < MAX_BATTERY_COUNT; idx++) {
if (!strlen(batteries[idx]) || !strcmp(batteries[idx], bat)) {
break;
}
if (!strlen(batteries[idx]) || !strcmp(batteries[idx], bat)) { break; }
}
/* if not found, enter a new entry */
if (!strlen(batteries[idx])) {
snprintf(batteries[idx], 31, "%s", bat);
}
if (!strlen(batteries[idx])) { snprintf(batteries[idx], 31, "%s", bat); }
return idx;
}
@ -1975,9 +1895,7 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat,
while (!feof(fp)) {
char b[256];
if (fgets(b, 256, fp) == nullptr) {
break;
}
if (fgets(b, 256, fp) == nullptr) { break; }
if (sscanf(b, "last full capacity: %d", &acpi_last_full[idx]) != 0) {
break;
}
@ -1994,9 +1912,7 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat,
while (!feof(acpi_bat_fp[idx])) {
char buf[256];
if (fgets(buf, 256, acpi_bat_fp[idx]) == nullptr) {
break;
}
if (fgets(buf, 256, acpi_bat_fp[idx]) == nullptr) { break; }
/* let's just hope units are ok */
if (strncmp(buf, "present:", 8) == 0) {
@ -2226,9 +2142,7 @@ int _get_battery_perct(const char *bat) {
while (!feof(fp)) {
char b[256];
if (fgets(b, 256, fp) == nullptr) {
break;
}
if (fgets(b, 256, fp) == nullptr) { break; }
if (sscanf(b, "last full capacity: %d", &acpi_design_capacity[idx]) !=
0) {
break;
@ -2243,18 +2157,14 @@ int _get_battery_perct(const char *bat) {
while (!feof(acpi_bat_fp[idx])) {
char buf[256];
if (fgets(buf, 256, acpi_bat_fp[idx]) == nullptr) {
break;
}
if (fgets(buf, 256, acpi_bat_fp[idx]) == nullptr) { break; }
if (buf[0] == 'r') {
sscanf(buf, "remaining capacity: %d", &remaining_capacity);
}
}
}
if (remaining_capacity < 0) {
return 0;
}
if (remaining_capacity < 0) { return 0; }
/* compute the battery percentage */
last_battery_perct[idx] =
(int)(((float)remaining_capacity / acpi_design_capacity[idx]) * 100);
@ -2328,8 +2238,10 @@ void get_powerbook_batt_info(struct text_object *obj, char *buffer, int n) {
static int rep = 0;
const char *batt_path = PMU_PATH "/battery_0";
const char *info_path = PMU_PATH "/info";
unsigned int flags;
int charge, max_charge, ac = -1;
unsigned int flags = 0;
int charge = 0;
int max_charge = 1;
int ac = -1;
long timeval = -1;
/* don't update battery too often */
@ -2341,9 +2253,7 @@ void get_powerbook_batt_info(struct text_object *obj, char *buffer, int n) {
if (pmu_battery_fp == nullptr) {
pmu_battery_fp = open_file(batt_path, &rep);
if (pmu_battery_fp == nullptr) {
return;
}
if (pmu_battery_fp == nullptr) { return; }
}
if (pmu_battery_fp != nullptr) {
@ -2351,9 +2261,7 @@ void get_powerbook_batt_info(struct text_object *obj, char *buffer, int n) {
while (!feof(pmu_battery_fp)) {
char buf[32];
if (fgets(buf, sizeof(buf), pmu_battery_fp) == nullptr) {
break;
}
if (fgets(buf, sizeof(buf), pmu_battery_fp) == nullptr) { break; }
if (buf[0] == 'f') {
sscanf(buf, "flags : %8x", &flags);
@ -2368,9 +2276,7 @@ void get_powerbook_batt_info(struct text_object *obj, char *buffer, int n) {
}
if (pmu_info_fp == nullptr) {
pmu_info_fp = open_file(info_path, &rep);
if (pmu_info_fp == nullptr) {
return;
}
if (pmu_info_fp == nullptr) { return; }
}
if (pmu_info_fp != nullptr) {
@ -2378,12 +2284,8 @@ void get_powerbook_batt_info(struct text_object *obj, char *buffer, int n) {
while (!feof(pmu_info_fp)) {
char buf[32];
if (fgets(buf, sizeof(buf), pmu_info_fp) == nullptr) {
break;
}
if (buf[0] == 'A') {
sscanf(buf, "AC Power : %d", &ac);
}
if (fgets(buf, sizeof(buf), pmu_info_fp) == nullptr) { break; }
if (buf[0] == 'A') { sscanf(buf, "AC Power : %d", &ac); }
}
}
/* update status string */
@ -2512,9 +2414,7 @@ int update_diskio(void) {
stats.current_read = 0;
stats.current_write = 0;
if (!(fp = open_file("/proc/diskstats", &rep))) {
return 0;
}
if (!(fp = open_file("/proc/diskstats", &rep))) { return 0; }
/* read reads and writes from all disks (minor = 0), including cd-roms
* and floppies, and sum them up */
@ -2535,9 +2435,7 @@ int update_diskio(void) {
} else {
col_count = sscanf(buf, "%u %u %s %*u %u %*u %u", &major, &minor, devbuf,
&reads, &writes);
if (col_count != 5) {
continue;
}
if (col_count != 5) { continue; }
}
cur = stats.next;
while (cur && strcmp(devbuf, cur->dev)) cur = cur->next;
@ -2611,9 +2509,7 @@ static unsigned long long calc_cpu_total(void) {
ps = open("/proc/stat", O_RDONLY);
rc = read(ps, line, BUFFER_LEN - 1);
close(ps);
if (rc < 0) {
return 0;
}
if (rc < 0) { return 0; }
sscanf(line, template_, &cpu, &niceval, &systemval, &idle, &iowait, &irq,
&softirq, &steal);
@ -2681,12 +2577,15 @@ static void process_parse_stat(struct process *process) {
process->pid);
ps = open(filename, O_RDONLY);
if (ps < 0) {
if (ps == -1) {
/* The process must have finished in the last few jiffies! */
return;
}
if (fstat(ps, &process_stat) != 0) return;
if (fstat(ps, &process_stat) != 0) {
close(ps);
return;
}
process->uid = process_stat.st_uid;
/* Mark process as up-to-date. */
@ -2694,9 +2593,7 @@ static void process_parse_stat(struct process *process) {
rc = read(ps, line, BUFFER_LEN - 1);
close(ps);
if (rc < 0) {
return;
}
if (rc < 0) { return; }
/* Read /proc/<pid>/cmdline */
cmdline_ps = open(cmdline_filename, O_RDONLY);
@ -2707,9 +2604,7 @@ static void process_parse_stat(struct process *process) {
endl = read(cmdline_ps, cmdline, BUFFER_LEN - 1);
close(cmdline_ps);
if (endl < 0) {
return;
}
if (endl < 0) { return; }
/* Some processes have null-separated arguments (see proc(5)); let's fix it */
int i = endl;
@ -2719,9 +2614,7 @@ static void process_parse_stat(struct process *process) {
}
while (i--) {
/* Replace null character between arguments with a space */
if (cmdline[i] == 0) {
cmdline[i] = ' ';
}
if (cmdline[i] == 0) { cmdline[i] = ' '; }
}
cmdline[endl] = 0;
@ -2833,9 +2726,7 @@ static void process_parse_io(struct process *process) {
rc = read(ps, line, BUFFER_LEN - 1);
close(ps);
if (rc < 0) {
return;
}
if (rc < 0) { return; }
pos = strstr(line, read_bytes_str);
if (pos == nullptr) {
@ -2844,19 +2735,13 @@ static void process_parse_io(struct process *process) {
}
pos += strlen(read_bytes_str);
process->read_bytes = strtoull(pos, &endpos, 10);
if (endpos == pos) {
return;
}
if (endpos == pos) { return; }
pos = strstr(line, write_bytes_str);
if (pos == nullptr) {
return;
}
if (pos == nullptr) { return; }
pos += strlen(write_bytes_str);
process->write_bytes = strtoull(pos, &endpos, 10);
if (endpos == pos) {
return;
}
if (endpos == pos) { return; }
if (process->previous_read_bytes == ULLONG_MAX) {
process->previous_read_bytes = process->read_bytes;
@ -2909,9 +2794,7 @@ static void update_process_table(void) {
DIR *dir;
struct dirent *entry;
if (!(dir = opendir("/proc"))) {
return;
}
if (!(dir = opendir("/proc"))) { return; }
info.run_procs = 0;
@ -2919,12 +2802,6 @@ static void update_process_table(void) {
while ((entry = readdir(dir))) {
pid_t pid;
if (!entry) {
/* Problem reading list of processes */
closedir(dir);
return;
}
if (sscanf(entry->d_name, "%d", &pid) > 0) {
/* compute each process cpu usage */
calculate_stats(get_process(pid));

View File

@ -21,11 +21,11 @@
*
*/
#include "llua.h"
#include <config.h>
#include "build.h"
#include "conky.h"
#include "llua.h"
#include "logging.h"
#include <config.h>
#ifdef BUILD_LUA_EXTRAS
extern "C" {
@ -76,9 +76,7 @@ class lua_load_setting : public conky::simple_config_setting<std::string> {
#ifdef HAVE_SYS_INOTIFY_H
llua_rm_notifies();
#endif /* HAVE_SYS_INOTIFY_H */
if (lua_L == nullptr) {
return;
}
if (lua_L == nullptr) { return; }
lua_close(lua_L);
lua_L = nullptr;
}
@ -143,9 +141,7 @@ static int llua_conky_set_update_interval(lua_State *L) {
void llua_init() {
const char *libs = PACKAGE_LIBDIR "/lib?.so;";
char *old_path, *new_path;
if (lua_L != nullptr) {
return;
}
if (lua_L != nullptr) { return; }
lua_L = luaL_newstate();
/* add our library path to the lua package.cpath global var */
@ -220,12 +216,11 @@ void llua_load(const char *script) {
static const char *tokenize(const char *str, size_t *len) {
str += *len;
*len = 0;
while ((str != nullptr) && (isspace(*str) != 0)) {
++str;
}
while ((str != nullptr) && (isspace(*str) != 0)) { ++str; }
size_t level = 0;
while ((str[*len] != 0) && (level > 0 || (isspace(str[*len]) == 0))) {
while ((str != nullptr) && (str[*len] != 0) &&
(level > 0 || (isspace(str[*len]) == 0))) {
switch (str[*len]) {
case '{':
++level;
@ -237,7 +232,7 @@ static const char *tokenize(const char *str, size_t *len) {
++*len;
}
if ((str[*len] == 0) && level > 0) {
if (str != nullptr && (str[*len] == 0) && level > 0) {
NORM_ERR("tokenize: improperly nested token: %s", str);
}
@ -258,9 +253,7 @@ static char *llua_do_call(const char *string, int retc) {
const char *ptr = tokenize(string, &len);
/* proceed only if the function name is present */
if (len == 0u) {
return nullptr;
}
if (len == 0U) { return nullptr; }
/* call only conky_ prefixed functions */
if (strncmp(ptr, LUAPREFIX, strlen(LUAPREFIX)) != 0) {
@ -319,9 +312,7 @@ static char *llua_getstring(const char *args) {
char *func;
char *ret = nullptr;
if (lua_L == nullptr) {
return nullptr;
}
if (lua_L == nullptr) { return nullptr; }
func = llua_do_call(args, 1);
if (func != nullptr) {
@ -366,9 +357,7 @@ static char *llua_getstring_read(const char *function, const char *arg)
static int llua_getnumber(const char *args, double *ret) {
char *func;
if (lua_L == nullptr) {
return 0;
}
if (lua_L == nullptr) { return 0; }
func = llua_do_call(args, 1);
if (func != nullptr) {
@ -410,9 +399,7 @@ void llua_append_notify(const char *name) {
new_tail = lua_notifies = llua_notify_list_do_alloc(name);
} else {
struct _lua_notify_s *tail = lua_notifies;
while (tail->next) {
tail = tail->next;
}
while (tail->next) { tail = tail->next; }
// should be @ the end now
new_tail = llua_notify_list_do_alloc(name);
tail->next = new_tail;
@ -467,31 +454,23 @@ void llua_set_number(const char *key, double value) {
}
void llua_startup_hook() {
if ((lua_L == nullptr) || lua_startup_hook.get(*state).empty()) {
return;
}
if ((lua_L == nullptr) || lua_startup_hook.get(*state).empty()) { return; }
llua_do_call(lua_startup_hook.get(*state).c_str(), 0);
}
void llua_shutdown_hook() {
if ((lua_L == nullptr) || lua_shutdown_hook.get(*state).empty()) {
return;
}
if ((lua_L == nullptr) || lua_shutdown_hook.get(*state).empty()) { return; }
llua_do_call(lua_shutdown_hook.get(*state).c_str(), 0);
}
#ifdef BUILD_X11
void llua_draw_pre_hook() {
if ((lua_L == nullptr) || lua_draw_hook_pre.get(*state).empty()) {
return;
}
if ((lua_L == nullptr) || lua_draw_hook_pre.get(*state).empty()) { return; }
llua_do_call(lua_draw_hook_pre.get(*state).c_str(), 0);
}
void llua_draw_post_hook() {
if ((lua_L == nullptr) || lua_draw_hook_post.get(*state).empty()) {
return;
}
if ((lua_L == nullptr) || lua_draw_hook_post.get(*state).empty()) { return; }
llua_do_call(lua_draw_hook_post.get(*state).c_str(), 0);
}
@ -504,9 +483,7 @@ void llua_set_userdata(const char *key, const char *type, void *value) {
void llua_setup_window_table(int text_start_x, int text_start_y, int text_width,
int text_height) {
if (lua_L == nullptr) {
return;
}
if (lua_L == nullptr) { return; }
lua_newtable(lua_L);
if (out_to_x.get(*state)) {
@ -533,9 +510,7 @@ void llua_setup_window_table(int text_start_x, int text_start_y, int text_width,
void llua_update_window_table(int text_start_x, int text_start_y,
int text_width, int text_height) {
if (lua_L == nullptr) {
return;
}
if (lua_L == nullptr) { return; }
lua_getglobal(lua_L, "conky_window");
if (lua_isnil(lua_L, -1)) {
@ -557,9 +532,7 @@ void llua_update_window_table(int text_start_x, int text_start_y,
#endif /* BUILD_X11 */
void llua_setup_info(struct information *i, double u_interval) {
if (lua_L == nullptr) {
return;
}
if (lua_L == nullptr) { return; }
lua_newtable(lua_L);
llua_set_number("update_interval", u_interval);
@ -569,9 +542,7 @@ void llua_setup_info(struct information *i, double u_interval) {
}
void llua_update_info(struct information *i, double u_interval) {
if (lua_L == nullptr) {
return;
}
if (lua_L == nullptr) { return; }
lua_getglobal(lua_L, "conky_info");
if (lua_isnil(lua_L, -1)) {
@ -604,8 +575,6 @@ void print_lua_parse(struct text_object *obj, char *p, int p_max_size) {
double lua_barval(struct text_object *obj) {
double per;
if (llua_getnumber(obj->data.s, &per) != 0) {
return per;
}
if (llua_getnumber(obj->data.s, &per) != 0) { return per; }
return 0;
}

View File

@ -199,6 +199,9 @@ static void mbox_scan(char *args, char *output, size_t max_len) {
prev = curr;
}
if (startlist == nullptr) {
return;
}
/* connect end to start for an endless loop-ring */
startlist->previous = curr;
curr->next = startlist;

View File

@ -264,7 +264,7 @@ void print_v6addrs(struct text_object *obj, char *p, int p_max_size) {
char tempaddress[INET6_ADDRSTRLEN];
struct v6addr *current_v6 = ns->v6addrs;
if (!ns) return;
if (ns == nullptr) return;
if (p_max_size == 0) return;
if (!ns->v6addrs) {

View File

@ -27,8 +27,8 @@
*
*/
#include "netbsd.h"
#include "net_stat.h"
#include "netbsd.h"
static kvm_t *kd = nullptr;
int kd_init = 0, nkd_init = 0;
@ -36,9 +36,7 @@ u_int32_t sensvalue;
char errbuf[_POSIX2_LINE_MAX];
static int init_kvm(void) {
if (kd_init) {
return 0;
}
if (kd_init) { return 0; }
kd = kvm_openfiles(nullptr, NULL, NULL, KVM_NO_FILES, errbuf);
if (kd == nullptr) {
@ -168,9 +166,7 @@ void update_net_stats() {
/* get delta */
delta = current_update_time - last_update_time;
if (delta <= 0.0001) {
return;
}
if (delta <= 0.0001) { return; }
for (i = 0, ifnetaddr = (u_long)ifhead.tqh_first;
ifnet.if_list.tqe_next && i < 16;
@ -212,7 +208,7 @@ void update_net_stats() {
}
}
void update_total_processes() {
int update_total_processes() {
/* It's easier to use kvm here than sysctl */
int n_processes;
@ -310,9 +306,7 @@ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size,
const char *adapter) {
(void)adapter; // only linux uses this
if (!p_client_buffer || client_buffer_size <= 0) {
return;
}
if (!p_client_buffer || client_buffer_size <= 0) { return; }
/* not implemented */
memset(p_client_buffer, 0, client_buffer_size);
@ -320,9 +314,7 @@ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size,
/* char *get_acpi_fan() */
void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size) {
if (!p_client_buffer || client_buffer_size <= 0) {
return;
}
if (!p_client_buffer || client_buffer_size <= 0) { return; }
/* not implemented */
memset(p_client_buffer, 0, client_buffer_size);

View File

@ -81,9 +81,7 @@ int init_kvm = 0;
int init_sensors = 0;
static int kvm_init() {
if (init_kvm) {
return 1;
}
if (init_kvm) { return 1; }
kd = kvm_open(nullptr, NULL, NULL, KVM_NO_FILES, NULL);
if (kd == nullptr) {
@ -103,14 +101,10 @@ static int swapmode(int *used, int *total) {
int nswap, rnswap, i;
nswap = swapctl(SWAP_NSWAP, 0, 0);
if (nswap == 0) {
return 0;
}
if (nswap == 0) { return 0; }
swdev = malloc(nswap * sizeof(*swdev));
if (swdev == nullptr) {
return 0;
}
if (swdev == nullptr) { return 0; }
rnswap = swapctl(SWAP_STATS, swdev, nswap);
if (rnswap == -1) {
@ -201,13 +195,9 @@ void update_net_stats() {
/* get delta */
delta = current_update_time - last_update_time;
if (delta <= 0.0001) {
return;
}
if (delta <= 0.0001) { return; }
if (getifaddrs(&ifap) < 0) {
return;
}
if (getifaddrs(&ifap) < 0) { return; }
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
ns = get_net_stat((const char *)ifa->ifa_name, nullptr, NULL);
@ -219,9 +209,7 @@ void update_net_stats() {
last_recv = ns->recv;
last_trans = ns->trans;
if (ifa->ifa_addr->sa_family != AF_LINK) {
continue;
}
if (ifa->ifa_addr->sa_family != AF_LINK) { continue; }
for (iftmp = ifa->ifa_next;
iftmp != nullptr && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
@ -262,7 +250,7 @@ void update_net_stats() {
freeifaddrs(ifap);
}
void update_total_processes() {
int update_total_processes() {
int n_processes;
kvm_init();
@ -281,9 +269,7 @@ void update_running_processes() {
p = kvm_getproc2(kd, KERN_PROC_ALL, 0, max_size, &n_processes);
for (i = 0; i < n_processes; i++) {
if (p[i].p_stat == SRUN) {
cnt++;
}
if (p[i].p_stat == SRUN) { cnt++; }
}
info.run_procs = cnt;
@ -321,9 +307,7 @@ void get_cpu_count() {
info.cpu_count = cpu_count;
info.cpu_usage = malloc(info.cpu_count * sizeof(float));
if (info.cpu_usage == nullptr) {
CRIT_ERR(nullptr, NULL, "malloc");
}
if (info.cpu_usage == nullptr) { CRIT_ERR(nullptr, NULL, "malloc"); }
#ifndef OLDCPU
assert(fresh == nullptr); /* XXX Is this leaking memory? */
@ -378,7 +362,8 @@ void update_cpu_usage() {
size = CPUSTATES * sizeof(int64_t);
for (i = 0; i < info.cpu_count; i++) {
int cp_time_mib[] = {CTL_KERN, KERN_CPTIME2, i};
if (sysctl(cp_time_mib, 3, &(fresh[i * CPUSTATES]), &size, nullptr, 0) < 0) {
if (sysctl(cp_time_mib, 3, &(fresh[i * CPUSTATES]), &size, nullptr, 0) <
0) {
NORM_ERR("sysctl kern.cp_time2 failed");
}
}
@ -391,9 +376,7 @@ void update_cpu_usage() {
NORM_ERR("sysctl kern.cp_time failed");
}
for (i = 0; i < CPUSTATES; i++) {
fresh[i] = (int64_t)cp_time_tmp[i];
}
for (i = 0; i < CPUSTATES; i++) { fresh[i] = (int64_t)cp_time_tmp[i]; }
}
/* XXX Do sg with this int64_t => long => double ? float hell. */
@ -456,9 +439,7 @@ void update_obsd_sensors() {
/* for (dev = 0; dev < MAXSENSORDEVICES; dev++) { */
mib[2] = dev;
if (sysctl(mib, 3, &sensordev, &sdlen, nullptr, 0) == -1) {
if (errno != ENOENT) {
warn("sysctl");
}
if (errno != ENOENT) { warn("sysctl"); }
return;
// continue;
}
@ -467,14 +448,10 @@ void update_obsd_sensors() {
for (numt = 0; numt < sensordev.maxnumt[type]; numt++) {
mib[4] = numt;
if (sysctl(mib, 5, &sensor, &slen, nullptr, 0) == -1) {
if (errno != ENOENT) {
warn("sysctl");
}
continue;
}
if (sensor.flags & SENSOR_FINVALID) {
if (errno != ENOENT) { warn("sysctl"); }
continue;
}
if (sensor.flags & SENSOR_FINVALID) { continue; }
switch (type) {
case SENSOR_TEMP:

View File

@ -101,10 +101,12 @@ void parse_tcp_ping_arg(struct text_object *obj, const char *arg,
"tcp_ping: Resolving 'localhost' also failed");
}
}
free(hostname);
addr->sin_port = htons(addr->sin_port);
addr->sin_family = he->h_addrtype;
memcpy(&(addr->sin_addr), he->h_addr, he->h_length);
if (he != nullptr) {
free(hostname);
addr->sin_port = htons(addr->sin_port);
addr->sin_family = he->h_addrtype;
memcpy(&(addr->sin_addr), he->h_addr, he->h_length);
}
}
void print_tcp_ping(struct text_object *obj, char *p, int p_max_size) {

View File

@ -181,7 +181,6 @@ double get_acpi_temperature(int fd) {
int update_total_processes(void) {
kstat_named_t *knp = get_kstat("unix", -1, "system_misc", "nproc");
if (knp != nullptr) info.procs = knp->value.ui32;
return 0;
}
void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item) {
@ -347,9 +346,7 @@ void get_top_info(void) {
DIR *dir;
struct dirent *entry;
if (!(dir = opendir("/proc"))) {
return;
}
if (!(dir = opendir("/proc"))) { return; }
info.run_procs = 0;
while ((entry = readdir(dir))) {

612
uncrustify.cfg Normal file
View File

@ -0,0 +1,612 @@
# Uncrustify-0.66.1_f
newlines = auto
input_tab_size = 8
output_tab_size = 8
string_escape_char = 92
string_escape_char2 = 0
string_replace_tab_chars = false
tok_split_gte = false
disable_processing_cmt = ""
enable_processing_cmt = ""
enable_digraphs = false
utf8_bom = ignore
utf8_byte = false
utf8_force = false
sp_arith = ignore
sp_arith_additive = ignore
sp_assign = ignore
sp_cpp_lambda_assign = ignore
sp_cpp_lambda_paren = ignore
sp_assign_default = ignore
sp_before_assign = ignore
sp_after_assign = ignore
sp_enum_paren = ignore
sp_enum_assign = ignore
sp_enum_before_assign = ignore
sp_enum_after_assign = ignore
sp_enum_colon = ignore
sp_pp_concat = add
sp_pp_stringify = ignore
sp_before_pp_stringify = ignore
sp_bool = ignore
sp_compare = ignore
sp_inside_paren = ignore
sp_paren_paren = ignore
sp_cparen_oparen = ignore
sp_balance_nested_parens = false
sp_paren_brace = ignore
sp_before_ptr_star = ignore
sp_before_unnamed_ptr_star = ignore
sp_between_ptr_star = ignore
sp_after_ptr_star = ignore
sp_after_ptr_star_qualifier = ignore
sp_after_ptr_star_func = ignore
sp_ptr_star_paren = ignore
sp_before_ptr_star_func = ignore
sp_before_byref = ignore
sp_before_unnamed_byref = ignore
sp_after_byref = ignore
sp_after_byref_func = ignore
sp_before_byref_func = ignore
sp_after_type = force
sp_before_template_paren = ignore
sp_template_angle = ignore
sp_before_angle = ignore
sp_inside_angle = ignore
sp_angle_colon = ignore
sp_after_angle = ignore
sp_angle_paren = ignore
sp_angle_paren_empty = ignore
sp_angle_word = ignore
sp_angle_shift = add
sp_permit_cpp11_shift = false
sp_before_sparen = ignore
sp_inside_sparen = ignore
sp_inside_sparen_close = ignore
sp_inside_sparen_open = ignore
sp_after_sparen = ignore
sp_sparen_brace = ignore
sp_invariant_paren = ignore
sp_after_invariant_paren = ignore
sp_special_semi = ignore
sp_before_semi = remove
sp_before_semi_for = ignore
sp_before_semi_for_empty = ignore
sp_after_semi = add
sp_after_semi_for = force
sp_after_semi_for_empty = ignore
sp_before_square = ignore
sp_before_squares = ignore
sp_inside_square = ignore
sp_after_comma = ignore
sp_before_comma = remove
sp_after_mdatype_commas = ignore
sp_before_mdatype_commas = ignore
sp_between_mdatype_commas = ignore
sp_paren_comma = force
sp_before_ellipsis = ignore
sp_after_class_colon = ignore
sp_before_class_colon = ignore
sp_after_constr_colon = ignore
sp_before_constr_colon = ignore
sp_before_case_colon = remove
sp_after_operator = ignore
sp_after_operator_sym = ignore
sp_after_operator_sym_empty = ignore
sp_after_cast = ignore
sp_inside_paren_cast = ignore
sp_cpp_cast_paren = ignore
sp_sizeof_paren = ignore
sp_after_tag = ignore
sp_inside_braces_enum = ignore
sp_inside_braces_struct = ignore
sp_after_type_brace_init_lst_open = ignore
sp_before_type_brace_init_lst_close = ignore
sp_inside_type_brace_init_lst = ignore
sp_inside_braces = ignore
sp_inside_braces_empty = ignore
sp_type_func = ignore
sp_type_brace_init_lst = ignore
sp_func_proto_paren = ignore
sp_func_proto_paren_empty = ignore
sp_func_def_paren = ignore
sp_func_def_paren_empty = ignore
sp_inside_fparens = ignore
sp_inside_fparen = ignore
sp_inside_tparen = ignore
sp_after_tparen_close = ignore
sp_square_fparen = ignore
sp_fparen_brace = ignore
sp_fparen_dbrace = ignore
sp_func_call_paren = ignore
sp_func_call_paren_empty = ignore
sp_func_call_user_paren = ignore
sp_func_class_paren = ignore
sp_func_class_paren_empty = ignore
sp_return_paren = ignore
sp_attribute_paren = ignore
sp_defined_paren = ignore
sp_throw_paren = ignore
sp_after_throw = ignore
sp_catch_paren = ignore
sp_version_paren = ignore
sp_scope_paren = ignore
sp_super_paren = remove
sp_this_paren = remove
sp_macro = ignore
sp_macro_func = ignore
sp_else_brace = ignore
sp_brace_else = ignore
sp_brace_typedef = ignore
sp_catch_brace = ignore
sp_brace_catch = ignore
sp_finally_brace = ignore
sp_brace_finally = ignore
sp_try_brace = ignore
sp_getset_brace = ignore
sp_word_brace = add
sp_word_brace_ns = add
sp_before_dc = ignore
sp_after_dc = ignore
sp_d_array_colon = ignore
sp_not = remove
sp_inv = remove
sp_addr = remove
sp_member = remove
sp_deref = remove
sp_sign = remove
sp_incdec = remove
sp_before_nl_cont = add
sp_after_oc_scope = ignore
sp_after_oc_colon = ignore
sp_before_oc_colon = ignore
sp_after_oc_dict_colon = ignore
sp_before_oc_dict_colon = ignore
sp_after_send_oc_colon = ignore
sp_before_send_oc_colon = ignore
sp_after_oc_type = ignore
sp_after_oc_return_type = ignore
sp_after_oc_at_sel = ignore
sp_after_oc_at_sel_parens = ignore
sp_inside_oc_at_sel_parens = ignore
sp_before_oc_block_caret = ignore
sp_after_oc_block_caret = ignore
sp_after_oc_msg_receiver = ignore
sp_after_oc_property = ignore
sp_cond_colon = ignore
sp_cond_colon_before = ignore
sp_cond_colon_after = ignore
sp_cond_question = ignore
sp_cond_question_before = ignore
sp_cond_question_after = ignore
sp_cond_ternary_short = ignore
sp_case_label = ignore
sp_range = ignore
sp_after_for_colon = ignore
sp_before_for_colon = ignore
sp_extern_paren = ignore
sp_cmt_cpp_start = ignore
sp_cmt_cpp_doxygen = false
sp_cmt_cpp_qttr = false
sp_endif_cmt = ignore
sp_after_new = ignore
sp_between_new_paren = ignore
sp_after_newop_paren = ignore
sp_inside_newop_paren = ignore
sp_inside_newop_paren_open = ignore
sp_inside_newop_paren_close = ignore
sp_before_tr_emb_cmt = ignore
sp_num_before_tr_emb_cmt = 0
sp_annotation_paren = ignore
sp_skip_vbrace_tokens = false
force_tab_after_define = false
indent_columns = 2
indent_continue = 0
indent_param = 0
indent_with_tabs = 0
indent_cmt_with_tabs = false
indent_align_string = false
indent_xml_string = 0
indent_brace = 0
indent_braces = false
indent_braces_no_func = false
indent_braces_no_class = false
indent_braces_no_struct = false
indent_brace_parent = false
indent_paren_open_brace = false
indent_cs_delegate_brace = false
indent_namespace = false
indent_namespace_single_indent = false
indent_namespace_level = 0
indent_namespace_limit = 0
indent_extern = false
indent_class = false
indent_class_colon = false
indent_class_on_colon = false
indent_constr_colon = false
indent_ctor_init_leading = 2
indent_ctor_init = 0
indent_else_if = false
indent_var_def_blk = 0
indent_var_def_cont = false
indent_shift = false
indent_func_def_force_col1 = false
indent_func_call_param = false
indent_func_def_param = false
indent_func_proto_param = false
indent_func_class_param = false
indent_func_ctor_var_param = false
indent_template_param = false
indent_func_param_double = false
indent_func_const = 0
indent_func_throw = 0
indent_member = 0
indent_sing_line_comments = 0
indent_relative_single_line_comments = false
indent_switch_case = 0
indent_switch_pp = true
indent_case_shift = 0
indent_case_brace = 0
indent_col1_comment = false
indent_label = 1
indent_access_spec = 1
indent_access_spec_body = false
indent_paren_nl = false
indent_paren_close = 0
indent_paren_after_func_def = false
indent_paren_after_func_decl = false
indent_paren_after_func_call = false
indent_comma_paren = false
indent_bool_paren = false
indent_first_bool_expr = false
indent_square_nl = false
indent_preserve_sql = false
indent_align_assign = true
indent_oc_block = false
indent_oc_block_msg = 0
indent_oc_msg_colon = 0
indent_oc_msg_prioritize_first_colon = true
indent_oc_block_msg_xcode_style = false
indent_oc_block_msg_from_keyword = false
indent_oc_block_msg_from_colon = false
indent_oc_block_msg_from_caret = false
indent_oc_block_msg_from_brace = false
indent_min_vbrace_open = 0
indent_vbrace_open_on_tabstop = false
indent_token_after_brace = true
indent_cpp_lambda_body = false
indent_using_block = true
indent_ternary_operator = 0
indent_ignore_asm_block = false
nl_collapse_empty_body = false
nl_assign_leave_one_liners = false
nl_class_leave_one_liners = false
nl_enum_leave_one_liners = false
nl_getset_leave_one_liners = false
nl_func_leave_one_liners = false
nl_cpp_lambda_leave_one_liners = false
nl_if_leave_one_liners = false
nl_while_leave_one_liners = false
nl_oc_msg_leave_one_liner = false
nl_oc_block_brace = ignore
nl_start_of_file = ignore
nl_start_of_file_min = 0
nl_end_of_file = ignore
nl_end_of_file_min = 0
nl_assign_brace = ignore
nl_assign_square = ignore
nl_after_square_assign = ignore
nl_func_var_def_blk = 0
nl_typedef_blk_start = 0
nl_typedef_blk_end = 0
nl_typedef_blk_in = 0
nl_var_def_blk_start = 0
nl_var_def_blk_end = 0
nl_var_def_blk_in = 0
nl_fcall_brace = ignore
nl_enum_brace = ignore
nl_enum_class = ignore
nl_enum_class_identifier = ignore
nl_enum_identifier_colon = ignore
nl_enum_colon_type = ignore
nl_struct_brace = ignore
nl_union_brace = ignore
nl_if_brace = ignore
nl_brace_else = ignore
nl_elseif_brace = ignore
nl_else_brace = ignore
nl_else_if = ignore
nl_before_if_closing_paren = ignore
nl_brace_finally = ignore
nl_finally_brace = ignore
nl_try_brace = ignore
nl_getset_brace = ignore
nl_for_brace = ignore
nl_catch_brace = ignore
nl_brace_catch = ignore
nl_brace_square = ignore
nl_brace_fparen = ignore
nl_while_brace = ignore
nl_scope_brace = ignore
nl_unittest_brace = ignore
nl_version_brace = ignore
nl_using_brace = ignore
nl_brace_brace = ignore
nl_do_brace = ignore
nl_brace_while = ignore
nl_switch_brace = ignore
nl_synchronized_brace = ignore
nl_multi_line_cond = false
nl_multi_line_define = false
nl_before_case = false
nl_before_throw = ignore
nl_after_case = false
nl_case_colon_brace = ignore
nl_namespace_brace = ignore
nl_template_class = ignore
nl_class_brace = ignore
nl_class_init_args = ignore
nl_constr_init_args = ignore
nl_enum_own_lines = ignore
nl_func_type_name = ignore
nl_func_type_name_class = ignore
nl_func_class_scope = ignore
nl_func_scope_name = ignore
nl_func_proto_type_name = ignore
nl_func_paren = ignore
nl_func_paren_empty = ignore
nl_func_def_paren = ignore
nl_func_def_paren_empty = ignore
nl_func_call_paren = ignore
nl_func_call_paren_empty = ignore
nl_func_decl_start = ignore
nl_func_def_start = ignore
nl_func_decl_start_single = ignore
nl_func_def_start_single = ignore
nl_func_decl_start_multi_line = false
nl_func_def_start_multi_line = false
nl_func_decl_args = ignore
nl_func_def_args = ignore
nl_func_decl_args_multi_line = false
nl_func_def_args_multi_line = false
nl_func_decl_end = ignore
nl_func_def_end = ignore
nl_func_decl_end_single = ignore
nl_func_def_end_single = ignore
nl_func_decl_end_multi_line = false
nl_func_def_end_multi_line = false
nl_func_decl_empty = ignore
nl_func_def_empty = ignore
nl_func_call_empty = ignore
nl_func_call_start_multi_line = false
nl_func_call_args_multi_line = false
nl_func_call_end_multi_line = false
nl_oc_msg_args = false
nl_fdef_brace = ignore
nl_cpp_ldef_brace = ignore
nl_return_expr = ignore
nl_after_semicolon = false
nl_paren_dbrace_open = ignore
nl_type_brace_init_lst = ignore
nl_type_brace_init_lst_open = ignore
nl_type_brace_init_lst_close = ignore
nl_after_brace_open = false
nl_after_brace_open_cmt = false
nl_after_vbrace_open = false
nl_after_vbrace_open_empty = false
nl_after_brace_close = false
nl_after_vbrace_close = false
nl_brace_struct_var = ignore
nl_define_macro = false
nl_squeeze_ifdef = false
nl_squeeze_ifdef_top_level = false
nl_before_if = ignore
nl_after_if = ignore
nl_before_for = ignore
nl_after_for = ignore
nl_before_while = ignore
nl_after_while = ignore
nl_before_switch = ignore
nl_after_switch = ignore
nl_before_synchronized = ignore
nl_after_synchronized = ignore
nl_before_do = ignore
nl_after_do = ignore
nl_ds_struct_enum_cmt = false
nl_ds_struct_enum_close_brace = false
nl_before_func_class_def = 0
nl_before_func_class_proto = 0
nl_class_colon = ignore
nl_constr_colon = ignore
nl_create_if_one_liner = false
nl_create_for_one_liner = false
nl_create_while_one_liner = false
nl_split_if_one_liner = false
nl_split_for_one_liner = false
nl_split_while_one_liner = false
nl_max = 0
nl_max_blank_in_func = 0
nl_after_func_proto = 0
nl_after_func_proto_group = 0
nl_after_func_class_proto = 0
nl_after_func_class_proto_group = 0
nl_before_func_body_def = 0
nl_before_func_body_proto = 0
nl_after_func_body = 0
nl_after_func_body_class = 0
nl_after_func_body_one_liner = 0
nl_before_block_comment = 0
nl_before_c_comment = 0
nl_before_cpp_comment = 0
nl_after_multiline_comment = false
nl_after_label_colon = false
nl_after_struct = 0
nl_before_class = 0
nl_after_class = 0
nl_before_access_spec = 0
nl_after_access_spec = 0
nl_comment_func_def = 0
nl_after_try_catch_finally = 0
nl_around_cs_property = 0
nl_between_get_set = 0
nl_property_brace = ignore
eat_blanks_after_open_brace = false
eat_blanks_before_close_brace = false
nl_remove_extra_newlines = 0
nl_before_return = false
nl_after_return = false
nl_after_annotation = ignore
nl_between_annotation = ignore
pos_arith = ignore
pos_assign = ignore
pos_bool = ignore
pos_compare = ignore
pos_conditional = ignore
pos_comma = ignore
pos_enum_comma = ignore
pos_class_comma = ignore
pos_constr_comma = ignore
pos_class_colon = ignore
pos_constr_colon = ignore
code_width = 0
ls_for_split_full = false
ls_func_split_full = false
ls_code_width = false
align_keep_tabs = false
align_with_tabs = false
align_on_tabstop = false
align_number_right = false
align_keep_extra_space = false
align_func_params = false
align_func_params_span = 0
align_func_params_thresh = 0
align_func_params_gap = 0
align_same_func_call_params = false
align_var_def_span = 0
align_var_def_star_style = 0
align_var_def_amp_style = 0
align_var_def_thresh = 0
align_var_def_gap = 0
align_var_def_colon = false
align_var_def_colon_gap = 0
align_var_def_attribute = false
align_var_def_inline = false
align_assign_span = 0
align_assign_thresh = 0
align_enum_equ_span = 0
align_enum_equ_thresh = 0
align_var_class_span = 0
align_var_class_thresh = 0
align_var_class_gap = 0
align_var_struct_span = 0
align_var_struct_thresh = 0
align_var_struct_gap = 0
align_struct_init_span = 0
align_typedef_gap = 0
align_typedef_span = 0
align_typedef_func = 0
align_typedef_star_style = 0
align_typedef_amp_style = 0
align_right_cmt_span = 0
align_right_cmt_mix = false
align_right_cmt_gap = 0
align_right_cmt_at_col = 0
align_func_proto_span = 0
align_func_proto_gap = 0
align_on_operator = false
align_mix_var_proto = false
align_single_line_func = false
align_single_line_brace = false
align_single_line_brace_gap = 0
align_oc_msg_spec_span = 0
align_nl_cont = false
align_pp_define_together = false
align_pp_define_gap = 0
align_pp_define_span = 0
align_left_shift = true
align_asm_colon = false
align_oc_msg_colon_span = 0
align_oc_msg_colon_first = false
align_oc_decl_colon = false
cmt_width = 0
cmt_reflow_mode = 0
cmt_convert_tab_to_spaces = false
cmt_indent_multi = true
cmt_c_group = false
cmt_c_nl_start = false
cmt_c_nl_end = false
cmt_cpp_group = false
cmt_cpp_nl_start = false
cmt_cpp_nl_end = false
cmt_cpp_to_c = false
cmt_star_cont = false
cmt_sp_before_star_cont = 0
cmt_sp_after_star_cont = 0
cmt_multi_check_last = true
cmt_multi_first_len_minimum = 4
cmt_insert_file_header = ""
cmt_insert_file_footer = ""
cmt_insert_func_header = ""
cmt_insert_class_header = ""
cmt_insert_oc_msg_header = ""
cmt_insert_before_preproc = false
cmt_insert_before_inlines = true
cmt_insert_before_ctor_dtor = false
mod_full_brace_do = ignore
mod_full_brace_for = ignore
mod_full_brace_function = ignore
mod_full_brace_if = ignore
mod_full_brace_if_chain = false
mod_full_brace_if_chain_only = false
mod_full_brace_nl = 0
mod_full_brace_nl_block_rem_mlcond = false
mod_full_brace_while = ignore
mod_full_brace_using = ignore
mod_paren_on_return = ignore
mod_pawn_semicolon = false
mod_full_paren_if_bool = false
mod_remove_extra_semicolon = false
mod_add_long_function_closebrace_comment = 0
mod_add_long_namespace_closebrace_comment = 0
mod_add_long_class_closebrace_comment = 0
mod_add_long_switch_closebrace_comment = 0
mod_add_long_ifdef_endif_comment = 0
mod_add_long_ifdef_else_comment = 0
mod_sort_import = false
mod_sort_using = false
mod_sort_include = false
mod_move_case_break = false
mod_case_brace = ignore
mod_remove_empty_return = false
mod_sort_oc_properties = false
mod_sort_oc_property_class_weight = 0
mod_sort_oc_property_thread_safe_weight = 0
mod_sort_oc_property_readwrite_weight = 0
mod_sort_oc_property_reference_weight = 0
mod_sort_oc_property_getter_weight = 0
mod_sort_oc_property_setter_weight = 0
mod_sort_oc_property_nullability_weight = 0
pp_indent = ignore
pp_indent_at_level = false
pp_indent_count = 1
pp_space = ignore
pp_space_count = 0
pp_indent_region = 0
pp_region_indent_code = false
pp_indent_if = 0
pp_if_indent_code = false
pp_define_at_level = false
pp_ignore_define_body = false
pp_indent_case = true
pp_indent_func_def = true
pp_indent_extern = true
pp_indent_brace = true
include_category_0 = ""
include_category_1 = ""
include_category_2 = ""
use_indent_func_call_param = true
use_indent_continue_only_once = false
use_options_overriding_for_qt_macros = true
warn_level_tabs_found_in_verbatim_string_literals = 2
# option(s) with 'not default' value: 0
#