mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-27 09:08:25 +00:00
Apply fixes from clang-tidy/format.
This commit is contained in:
parent
90673cf161
commit
46abd3b75a
@ -129,14 +129,14 @@ enum arg_type get_arg_type(const char *arg) {
|
||||
p++;
|
||||
}
|
||||
while (p <= e) {
|
||||
if (isdigit((unsigned char)*p) == 0) { break; }
|
||||
if (isdigit(static_cast<unsigned char>(*p)) == 0) { break; }
|
||||
p++;
|
||||
}
|
||||
if (p == e + 1) { return ARG_LONG; }
|
||||
if (*p == '.' || *p == ',') {
|
||||
p++;
|
||||
while (p <= e) {
|
||||
if (isdigit((unsigned char)*p) == 0) { return ARG_BAD; }
|
||||
if (isdigit(static_cast<unsigned char>(*p)) == 0) { return ARG_BAD; }
|
||||
p++;
|
||||
}
|
||||
return ARG_DOUBLE;
|
||||
|
@ -41,7 +41,7 @@ class errno_error : public std::runtime_error {
|
||||
typedef std::runtime_error Base;
|
||||
|
||||
public:
|
||||
errno_error(const std::string &prefix, int err_ = errno)
|
||||
explicit errno_error(const std::string &prefix, int err_ = errno)
|
||||
: Base(prefix + ": " + strerror_r(err_)), err(err_) {}
|
||||
|
||||
const int err;
|
||||
|
@ -50,8 +50,10 @@ size_t curl_internal::parse_header_cb(void *ptr, size_t size, size_t nmemb,
|
||||
const char *value = static_cast<const char *>(ptr);
|
||||
size_t realsize = size * nmemb;
|
||||
|
||||
if (realsize > 0 && (value[realsize - 1] == '\r' || value[realsize - 1] == 0))
|
||||
if (realsize > 0 &&
|
||||
(value[realsize - 1] == '\r' || value[realsize - 1] == 0)) {
|
||||
--realsize;
|
||||
}
|
||||
|
||||
if (strncmp(value, "Last-Modified: ", 15) == EQUAL) {
|
||||
obj->last_modified = std::string(value + 15, realsize - 15);
|
||||
@ -182,7 +184,7 @@ void curl_parse_arg(struct text_object *obj, const char *arg) {
|
||||
struct curl_data *cd;
|
||||
float interval = 0;
|
||||
|
||||
cd = (struct curl_data *)malloc(sizeof(struct curl_data));
|
||||
cd = static_cast<struct curl_data *>(malloc(sizeof(struct curl_data)));
|
||||
memset(cd, 0, sizeof(struct curl_data));
|
||||
|
||||
argc = sscanf(arg, "%127s %f", cd->uri, &interval);
|
||||
@ -191,15 +193,16 @@ void curl_parse_arg(struct text_object *obj, const char *arg) {
|
||||
NORM_ERR("wrong number of arguments for $curl");
|
||||
return;
|
||||
}
|
||||
if (argc == 1)
|
||||
if (argc == 1) {
|
||||
cd->interval = 15 * 60;
|
||||
else
|
||||
} else {
|
||||
cd->interval = interval > 0 ? interval * 60 : active_update_interval();
|
||||
}
|
||||
obj->data.opaque = cd;
|
||||
}
|
||||
|
||||
void curl_print(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||
struct curl_data *cd = (struct curl_data *)obj->data.opaque;
|
||||
struct curl_data *cd = static_cast<struct curl_data *>(obj->data.opaque);
|
||||
|
||||
if (!cd) {
|
||||
NORM_ERR("error processing Curl data");
|
||||
|
46
src/cmus.cc
46
src/cmus.cc
@ -59,7 +59,7 @@ class cmus_cb : public conky::callback<cmus_result> {
|
||||
virtual void work();
|
||||
|
||||
public:
|
||||
cmus_cb(uint32_t period) : Base(period, false, Tuple()) {}
|
||||
explicit cmus_cb(uint32_t period) : Base(period, false, Tuple()) {}
|
||||
};
|
||||
|
||||
void cmus_cb::work() {
|
||||
@ -79,53 +79,55 @@ void cmus_cb::work() {
|
||||
if ((p = strrchr(line, '\n'))) *p = '\0';
|
||||
|
||||
/* Parse infos. */
|
||||
if (strncmp(line, "status ", 7) == 0)
|
||||
if (strncmp(line, "status ", 7) == 0) {
|
||||
cmus.state = line + 7;
|
||||
|
||||
else if (strncmp(line, "file ", 5) == 0)
|
||||
} else if (strncmp(line, "file ", 5) == 0) {
|
||||
cmus.file = line + 5;
|
||||
|
||||
else if (strncmp(line, "tag artist ", 11) == 0)
|
||||
} else if (strncmp(line, "tag artist ", 11) == 0) {
|
||||
cmus.artist = line + 11;
|
||||
|
||||
else if (strncmp(line, "tag title ", 10) == 0)
|
||||
} else if (strncmp(line, "tag title ", 10) == 0) {
|
||||
cmus.title = line + 10;
|
||||
|
||||
else if (strncmp(line, "tag album ", 10) == 0)
|
||||
} else if (strncmp(line, "tag album ", 10) == 0) {
|
||||
cmus.album = line + 10;
|
||||
|
||||
else if (strncmp(line, "duration ", 9) == 0)
|
||||
} else if (strncmp(line, "duration ", 9) == 0) {
|
||||
cmus.totaltime = line + 9;
|
||||
|
||||
else if (strncmp(line, "position ", 9) == 0) {
|
||||
} else if (strncmp(line, "position ", 9) == 0) {
|
||||
cmus.curtime = line + 9;
|
||||
cmus.timeleft =
|
||||
atoi(cmus.totaltime.c_str()) - atoi(cmus.curtime.c_str());
|
||||
if (cmus.curtime.size() > 0)
|
||||
cmus.progress =
|
||||
(float)atoi(cmus.curtime.c_str()) / atoi(cmus.totaltime.c_str());
|
||||
else
|
||||
if (cmus.curtime.size() > 0) {
|
||||
cmus.progress = static_cast<float>(atoi(cmus.curtime.c_str())) /
|
||||
atoi(cmus.totaltime.c_str());
|
||||
} else {
|
||||
cmus.progress = 0;
|
||||
}
|
||||
}
|
||||
|
||||
else if (strncmp(line, "set shuffle ", 12) == 0)
|
||||
else if (strncmp(line, "set shuffle ", 12) == 0) {
|
||||
cmus.random = (strncmp(line + 12, "true", 4) == 0 ? "on" : "off");
|
||||
|
||||
else if (strncmp(line, "set repeat ", 11) == 0)
|
||||
} else if (strncmp(line, "set repeat ", 11) == 0) {
|
||||
cmus.repeat = (strncmp((line + 11), "true", 4) == 0 ? "all" : "off");
|
||||
|
||||
else if (strncmp(line, "set repeat_current ", 19) == 0)
|
||||
} else if (strncmp(line, "set repeat_current ", 19) == 0) {
|
||||
cmus.repeat =
|
||||
(strncmp((line + 19), "true", 4) == 0 ? "song" : cmus.repeat);
|
||||
else if (strncmp(line, "set aaa_mode ", 13) == 0)
|
||||
} else if (strncmp(line, "set aaa_mode ", 13) == 0) {
|
||||
cmus.aaa = line + 13;
|
||||
|
||||
else if (strncmp(line, "tag tracknumber ", 16) == 0)
|
||||
} else if (strncmp(line, "tag tracknumber ", 16) == 0) {
|
||||
cmus.track = line + 16;
|
||||
else if (strncmp(line, "tag genre ", 10) == 0)
|
||||
} else if (strncmp(line, "tag genre ", 10) == 0) {
|
||||
cmus.genre = line + 10;
|
||||
else if (strncmp(line, "tag date ", 9) == 0)
|
||||
} else if (strncmp(line, "tag date ", 9) == 0) {
|
||||
cmus.date = line + 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,7 +169,7 @@ uint8_t cmus_percent(struct text_object *obj) {
|
||||
lround(music_player_interval.get(*state) / active_update_interval()), 1l);
|
||||
const cmus_result &cmus =
|
||||
conky::register_cb<cmus_cb>(period)->get_result_copy();
|
||||
return (uint8_t)round(cmus.progress * 100.0f);
|
||||
return static_cast<uint8_t>(round(cmus.progress * 100.0f));
|
||||
}
|
||||
|
||||
double cmus_progress(struct text_object *obj) {
|
||||
@ -176,7 +178,7 @@ double cmus_progress(struct text_object *obj) {
|
||||
lround(music_player_interval.get(*state) / active_update_interval()), 1l);
|
||||
const cmus_result &cmus =
|
||||
conky::register_cb<cmus_cb>(period)->get_result_copy();
|
||||
return (double)cmus.progress;
|
||||
return static_cast<double>(cmus.progress);
|
||||
}
|
||||
|
||||
void print_cmus_totaltime(struct text_object *obj, char *p,
|
||||
@ -197,7 +199,7 @@ void print_cmus_timeleft(struct text_object *obj, char *p,
|
||||
const cmus_result &cmus =
|
||||
conky::register_cb<cmus_cb>(period)->get_result_copy();
|
||||
// format_seconds_short(p, p_max_size, atol(cmus.timeleft.c_str()));
|
||||
format_seconds_short(p, p_max_size, (long)cmus.timeleft);
|
||||
format_seconds_short(p, p_max_size, static_cast<long>(cmus.timeleft));
|
||||
}
|
||||
|
||||
void print_cmus_curtime(struct text_object *obj, char *p,
|
||||
|
@ -183,10 +183,10 @@ std::string variable_substitute(std::string s) {
|
||||
std::string var;
|
||||
std::string::size_type l = 0;
|
||||
|
||||
if (isalpha((unsigned char)s[pos + 1]) != 0) {
|
||||
if (isalpha(static_cast<unsigned char>(s[pos + 1])) != 0) {
|
||||
l = 1;
|
||||
while (pos + l < s.size() &&
|
||||
(isalnum((unsigned char)s[pos + l]) != 0)) {
|
||||
(isalnum(static_cast<unsigned char>(s[pos + l])) != 0)) {
|
||||
++l;
|
||||
}
|
||||
var = s.substr(pos + 1, l - 1);
|
||||
@ -313,7 +313,7 @@ unsigned int round_to_int(float f) {
|
||||
void scan_loadavg_arg(struct text_object *obj, const char *arg) {
|
||||
obj->data.i = 0;
|
||||
if ((arg != nullptr) && (arg[1] == 0) &&
|
||||
(isdigit((unsigned char)arg[0]) != 0)) {
|
||||
(isdigit(static_cast<unsigned char>(arg[0])) != 0)) {
|
||||
obj->data.i = atoi(arg);
|
||||
if (obj->data.i > 3 || obj->data.i < 1) {
|
||||
NORM_ERR("loadavg arg needs to be in range (1,3)");
|
||||
@ -364,7 +364,7 @@ double loadgraphval(struct text_object *obj) {
|
||||
#endif /* BUILD_X11 */
|
||||
|
||||
uint8_t cpu_percentage(struct text_object *obj) {
|
||||
if ((unsigned int)obj->data.i > info.cpu_count) {
|
||||
if (static_cast<unsigned int>(obj->data.i) > info.cpu_count) {
|
||||
NORM_ERR("obj->data.i %i info.cpu_count %i", obj->data.i, info.cpu_count);
|
||||
CRIT_ERR(nullptr, nullptr, "attempting to use more CPUs than you have!");
|
||||
}
|
||||
@ -777,7 +777,7 @@ error:
|
||||
if (nullptr != curl) { curl_easy_cleanup(curl); }
|
||||
curl_global_cleanup();
|
||||
|
||||
if (!isdigit((unsigned char)*p)) { last_update = 1U; }
|
||||
if (!isdigit(static_cast<unsigned char>(*p))) { last_update = 1U; }
|
||||
}
|
||||
|
||||
void print_stock(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||
|
@ -784,7 +784,7 @@ static void generate_text() {
|
||||
|
||||
tmp_p = text_buffer;
|
||||
while (*tmp_p != 0) {
|
||||
*tmp_p = toupper((unsigned char)*tmp_p);
|
||||
*tmp_p = toupper(static_cast<unsigned char>(*tmp_p));
|
||||
tmp_p++;
|
||||
}
|
||||
}
|
||||
@ -2205,7 +2205,7 @@ void main_loop() {
|
||||
#endif /* BUILD_X11 */
|
||||
struct timespec req, rem;
|
||||
auto time_to_sleep = next_update_time - get_time();
|
||||
auto seconds = (time_t)std::floor(time_to_sleep);
|
||||
auto seconds = static_cast<time_t>(std::floor(time_to_sleep));
|
||||
auto nanos = (time_to_sleep - seconds) * 1000000000L;
|
||||
req.tv_sec = seconds;
|
||||
req.tv_nsec = nanos;
|
||||
|
187
src/core.cc
187
src/core.cc
@ -172,171 +172,171 @@ void stock_parse_arg(struct text_object *obj, const char *arg) {
|
||||
NORM_ERR("wrong number of arguments for $stock");
|
||||
return;
|
||||
}
|
||||
if (!strcasecmp("ask", data))
|
||||
if (!strcasecmp("ask", data)) {
|
||||
strncpy(data, "a", 3);
|
||||
else if (!strcasecmp("adv", data))
|
||||
} else if (!strcasecmp("adv", data)) {
|
||||
strncpy(data, "a2", 3);
|
||||
else if (!strcasecmp("asksize", data))
|
||||
} else if (!strcasecmp("asksize", data)) {
|
||||
strncpy(data, "a5", 3);
|
||||
else if (!strcasecmp("bid", data))
|
||||
} else if (!strcasecmp("bid", data)) {
|
||||
strncpy(data, "b", 3);
|
||||
else if (!strcasecmp("askrt", data))
|
||||
} else if (!strcasecmp("askrt", data)) {
|
||||
strncpy(data, "b2", 3);
|
||||
else if (!strcasecmp("bidrt", data))
|
||||
} else if (!strcasecmp("bidrt", data)) {
|
||||
strncpy(data, "b3", 3);
|
||||
else if (!strcasecmp("bookvalue", data))
|
||||
} else if (!strcasecmp("bookvalue", data)) {
|
||||
strncpy(data, "b4", 3);
|
||||
else if (!strcasecmp("bidsize", data))
|
||||
} else if (!strcasecmp("bidsize", data)) {
|
||||
strncpy(data, "b6", 3);
|
||||
else if (!strcasecmp("change", data))
|
||||
} else if (!strcasecmp("change", data)) {
|
||||
strncpy(data, "c1", 3);
|
||||
else if (!strcasecmp("commission", data))
|
||||
} else if (!strcasecmp("commission", data)) {
|
||||
strncpy(data, "c3", 3);
|
||||
else if (!strcasecmp("changert", data))
|
||||
} else if (!strcasecmp("changert", data)) {
|
||||
strncpy(data, "c6", 3);
|
||||
else if (!strcasecmp("ahcrt", data))
|
||||
} else if (!strcasecmp("ahcrt", data)) {
|
||||
strncpy(data, "c8", 3);
|
||||
else if (!strcasecmp("ds", data))
|
||||
} else if (!strcasecmp("ds", data)) {
|
||||
strncpy(data, "d", 3);
|
||||
else if (!strcasecmp("ltd", data))
|
||||
} else if (!strcasecmp("ltd", data)) {
|
||||
strncpy(data, "d1", 3);
|
||||
else if (!strcasecmp("tradedate", data))
|
||||
} else if (!strcasecmp("tradedate", data)) {
|
||||
strncpy(data, "d2", 3);
|
||||
else if (!strcasecmp("es", data))
|
||||
} else if (!strcasecmp("es", data)) {
|
||||
strncpy(data, "e", 3);
|
||||
else if (!strcasecmp("ei", data))
|
||||
} else if (!strcasecmp("ei", data)) {
|
||||
strncpy(data, "e1", 3);
|
||||
else if (!strcasecmp("epsecy", data))
|
||||
} else if (!strcasecmp("epsecy", data)) {
|
||||
strncpy(data, "e7", 3);
|
||||
else if (!strcasecmp("epseny", data))
|
||||
} else if (!strcasecmp("epseny", data)) {
|
||||
strncpy(data, "e8", 3);
|
||||
else if (!strcasecmp("epsenq", data))
|
||||
} else if (!strcasecmp("epsenq", data)) {
|
||||
strncpy(data, "e9", 3);
|
||||
else if (!strcasecmp("floatshares", data))
|
||||
} else if (!strcasecmp("floatshares", data)) {
|
||||
strncpy(data, "f6", 3);
|
||||
else if (!strcasecmp("dayslow", data))
|
||||
} else if (!strcasecmp("dayslow", data)) {
|
||||
strncpy(data, "g", 3);
|
||||
else if (!strcasecmp("dayshigh", data))
|
||||
} else if (!strcasecmp("dayshigh", data)) {
|
||||
strncpy(data, "h", 3);
|
||||
else if (!strcasecmp("52weeklow", data))
|
||||
} else if (!strcasecmp("52weeklow", data)) {
|
||||
strncpy(data, "j", 3);
|
||||
else if (!strcasecmp("52weekhigh", data))
|
||||
} else if (!strcasecmp("52weekhigh", data)) {
|
||||
strncpy(data, "k", 3);
|
||||
else if (!strcasecmp("hgp", data))
|
||||
} else if (!strcasecmp("hgp", data)) {
|
||||
strncpy(data, "g1", 3);
|
||||
else if (!strcasecmp("ag", data))
|
||||
} else if (!strcasecmp("ag", data)) {
|
||||
strncpy(data, "g3", 3);
|
||||
else if (!strcasecmp("hg", data))
|
||||
} else if (!strcasecmp("hg", data)) {
|
||||
strncpy(data, "g4", 3);
|
||||
else if (!strcasecmp("hgprt", data))
|
||||
} else if (!strcasecmp("hgprt", data)) {
|
||||
strncpy(data, "g5", 3);
|
||||
else if (!strcasecmp("hgrt", data))
|
||||
} else if (!strcasecmp("hgrt", data)) {
|
||||
strncpy(data, "g6", 3);
|
||||
else if (!strcasecmp("moreinfo", data))
|
||||
} else if (!strcasecmp("moreinfo", data)) {
|
||||
strncpy(data, "i", 3);
|
||||
else if (!strcasecmp("obrt", data))
|
||||
} else if (!strcasecmp("obrt", data)) {
|
||||
strncpy(data, "i5", 3);
|
||||
else if (!strcasecmp("mc", data))
|
||||
} else if (!strcasecmp("mc", data)) {
|
||||
strncpy(data, "j1", 3);
|
||||
else if (!strcasecmp("mcrt", data))
|
||||
} else if (!strcasecmp("mcrt", data)) {
|
||||
strncpy(data, "j3", 3);
|
||||
else if (!strcasecmp("ebitda", data))
|
||||
} else if (!strcasecmp("ebitda", data)) {
|
||||
strncpy(data, "j4", 3);
|
||||
else if (!strcasecmp("c52wlow", data))
|
||||
} else if (!strcasecmp("c52wlow", data)) {
|
||||
strncpy(data, "j5", 3);
|
||||
else if (!strcasecmp("pc52wlow", data))
|
||||
} else if (!strcasecmp("pc52wlow", data)) {
|
||||
strncpy(data, "j6", 3);
|
||||
else if (!strcasecmp("cprt", data))
|
||||
} else if (!strcasecmp("cprt", data)) {
|
||||
strncpy(data, "k2", 3);
|
||||
else if (!strcasecmp("lts", data))
|
||||
} else if (!strcasecmp("lts", data)) {
|
||||
strncpy(data, "k3", 3);
|
||||
else if (!strcasecmp("c52whigh", data))
|
||||
} else if (!strcasecmp("c52whigh", data)) {
|
||||
strncpy(data, "k4", 3);
|
||||
else if (!strcasecmp("pc52whigh", data))
|
||||
} else if (!strcasecmp("pc52whigh", data)) {
|
||||
strncpy(data, "k5", 3);
|
||||
else if (!strcasecmp("ltp", data))
|
||||
} else if (!strcasecmp("ltp", data)) {
|
||||
strncpy(data, "l1", 3);
|
||||
else if (!strcasecmp("hl", data))
|
||||
} else if (!strcasecmp("hl", data)) {
|
||||
strncpy(data, "l2", 3);
|
||||
else if (!strcasecmp("ll", data))
|
||||
} else if (!strcasecmp("ll", data)) {
|
||||
strncpy(data, "l3", 3);
|
||||
else if (!strcasecmp("dr", data))
|
||||
} else if (!strcasecmp("dr", data)) {
|
||||
strncpy(data, "m", 3);
|
||||
else if (!strcasecmp("drrt", data))
|
||||
} else if (!strcasecmp("drrt", data)) {
|
||||
strncpy(data, "m2", 3);
|
||||
else if (!strcasecmp("50ma", data))
|
||||
} else if (!strcasecmp("50ma", data)) {
|
||||
strncpy(data, "m3", 3);
|
||||
else if (!strcasecmp("200ma", data))
|
||||
} else if (!strcasecmp("200ma", data)) {
|
||||
strncpy(data, "m4", 3);
|
||||
else if (!strcasecmp("c200ma", data))
|
||||
} else if (!strcasecmp("c200ma", data)) {
|
||||
strncpy(data, "m5", 3);
|
||||
else if (!strcasecmp("pc200ma", data))
|
||||
} else if (!strcasecmp("pc200ma", data)) {
|
||||
strncpy(data, "m6", 3);
|
||||
else if (!strcasecmp("c50ma", data))
|
||||
} else if (!strcasecmp("c50ma", data)) {
|
||||
strncpy(data, "m7", 3);
|
||||
else if (!strcasecmp("pc50ma", data))
|
||||
} else if (!strcasecmp("pc50ma", data)) {
|
||||
strncpy(data, "m8", 3);
|
||||
else if (!strcasecmp("name", data))
|
||||
} else if (!strcasecmp("name", data)) {
|
||||
strncpy(data, "n", 3);
|
||||
else if (!strcasecmp("notes", data))
|
||||
} else if (!strcasecmp("notes", data)) {
|
||||
strncpy(data, "n4", 3);
|
||||
else if (!strcasecmp("open", data))
|
||||
} else if (!strcasecmp("open", data)) {
|
||||
strncpy(data, "o", 3);
|
||||
else if (!strcasecmp("pc", data))
|
||||
} else if (!strcasecmp("pc", data)) {
|
||||
strncpy(data, "p", 3);
|
||||
else if (!strcasecmp("pricepaid", data))
|
||||
} else if (!strcasecmp("pricepaid", data)) {
|
||||
strncpy(data, "p1", 3);
|
||||
else if (!strcasecmp("cip", data))
|
||||
} else if (!strcasecmp("cip", data)) {
|
||||
strncpy(data, "p2", 3);
|
||||
else if (!strcasecmp("ps", data))
|
||||
} else if (!strcasecmp("ps", data)) {
|
||||
strncpy(data, "p5", 3);
|
||||
else if (!strcasecmp("pb", data))
|
||||
} else if (!strcasecmp("pb", data)) {
|
||||
strncpy(data, "p6", 3);
|
||||
else if (!strcasecmp("edv", data))
|
||||
} else if (!strcasecmp("edv", data)) {
|
||||
strncpy(data, "q", 3);
|
||||
else if (!strcasecmp("per", data))
|
||||
} else if (!strcasecmp("per", data)) {
|
||||
strncpy(data, "r", 3);
|
||||
else if (!strcasecmp("dpd", data))
|
||||
} else if (!strcasecmp("dpd", data)) {
|
||||
strncpy(data, "r1", 3);
|
||||
else if (!strcasecmp("perrt", data))
|
||||
} else if (!strcasecmp("perrt", data)) {
|
||||
strncpy(data, "r2", 3);
|
||||
else if (!strcasecmp("pegr", data))
|
||||
} else if (!strcasecmp("pegr", data)) {
|
||||
strncpy(data, "r5", 3);
|
||||
else if (!strcasecmp("pepsecy", data))
|
||||
} else if (!strcasecmp("pepsecy", data)) {
|
||||
strncpy(data, "r6", 3);
|
||||
else if (!strcasecmp("pepseny", data))
|
||||
} else if (!strcasecmp("pepseny", data)) {
|
||||
strncpy(data, "r7", 3);
|
||||
else if (!strcasecmp("symbol", data))
|
||||
} else if (!strcasecmp("symbol", data)) {
|
||||
strncpy(data, "s", 3);
|
||||
else if (!strcasecmp("sharesowned", data))
|
||||
} else if (!strcasecmp("sharesowned", data)) {
|
||||
strncpy(data, "s1", 3);
|
||||
else if (!strcasecmp("shortratio", data))
|
||||
} else if (!strcasecmp("shortratio", data)) {
|
||||
strncpy(data, "s7", 3);
|
||||
else if (!strcasecmp("ltt", data))
|
||||
} else if (!strcasecmp("ltt", data)) {
|
||||
strncpy(data, "t1", 3);
|
||||
else if (!strcasecmp("tradelinks", data))
|
||||
} else if (!strcasecmp("tradelinks", data)) {
|
||||
strncpy(data, "t6", 3);
|
||||
else if (!strcasecmp("tt", data))
|
||||
} else if (!strcasecmp("tt", data)) {
|
||||
strncpy(data, "t7", 3);
|
||||
else if (!strcasecmp("1ytp", data))
|
||||
} else if (!strcasecmp("1ytp", data)) {
|
||||
strncpy(data, "t8", 3);
|
||||
else if (!strcasecmp("volume", data))
|
||||
} else if (!strcasecmp("volume", data)) {
|
||||
strncpy(data, "v", 3);
|
||||
else if (!strcasecmp("hv", data))
|
||||
} else if (!strcasecmp("hv", data)) {
|
||||
strncpy(data, "v1", 3);
|
||||
else if (!strcasecmp("hvrt", data))
|
||||
} else if (!strcasecmp("hvrt", data)) {
|
||||
strncpy(data, "v7", 3);
|
||||
else if (!strcasecmp("52weekrange", data))
|
||||
} else if (!strcasecmp("52weekrange", data)) {
|
||||
strncpy(data, "w", 3);
|
||||
else if (!strcasecmp("dvc", data))
|
||||
} else if (!strcasecmp("dvc", data)) {
|
||||
strncpy(data, "w1", 3);
|
||||
else if (!strcasecmp("dvcrt", data))
|
||||
} else if (!strcasecmp("dvcrt", data)) {
|
||||
strncpy(data, "w4", 3);
|
||||
else if (!strcasecmp("se", data))
|
||||
} else if (!strcasecmp("se", data)) {
|
||||
strncpy(data, "x", 3);
|
||||
else if (!strcasecmp("dy", data))
|
||||
} else if (!strcasecmp("dy", data)) {
|
||||
strncpy(data, "y", 3);
|
||||
else {
|
||||
} else {
|
||||
NORM_ERR(
|
||||
"\"%s\" is not supported by $stock. Supported: 1ytp, 200ma, 50ma, "
|
||||
"52weeklow, 52weekhigh, 52weekrange, adv, ag, ahcrt, ask, askrt, "
|
||||
@ -352,7 +352,7 @@ void stock_parse_arg(struct text_object *obj, const char *arg) {
|
||||
return;
|
||||
}
|
||||
#define MAX_FINYAH_URL_LENGTH 64
|
||||
obj->data.s = (char *)malloc(MAX_FINYAH_URL_LENGTH);
|
||||
obj->data.s = static_cast<char *>(malloc(MAX_FINYAH_URL_LENGTH));
|
||||
snprintf(obj->data.s, MAX_FINYAH_URL_LENGTH,
|
||||
"http://download.finance.yahoo.com/d/quotes.csv?s=%s&f=%s", stock,
|
||||
data);
|
||||
@ -429,9 +429,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
||||
obj->callbacks.free = &gen_free_opaque;
|
||||
#endif /* !__OpenBSD__ */
|
||||
END OBJ(freq, nullptr) get_cpu_count();
|
||||
if ((arg == nullptr) || (isdigit((unsigned char)arg[0]) == 0) ||
|
||||
if ((arg == nullptr) || (isdigit(static_cast<unsigned char>(arg[0])) == 0) ||
|
||||
strlen(arg) >= 3 || atoi(&arg[0]) == 0 ||
|
||||
(unsigned int)atoi(&arg[0]) > info.cpu_count) {
|
||||
static_cast<unsigned int>(atoi(&arg[0])) > info.cpu_count) {
|
||||
obj->data.i = 1;
|
||||
/* NORM_ERR("freq: Invalid CPU number or you don't have that many CPUs! "
|
||||
"Displaying the clock for CPU 1."); */
|
||||
@ -440,9 +440,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
||||
}
|
||||
obj->callbacks.print = &print_freq;
|
||||
END OBJ(freq_g, nullptr) get_cpu_count();
|
||||
if ((arg == nullptr) || (isdigit((unsigned char)arg[0]) == 0) ||
|
||||
if ((arg == nullptr) || (isdigit(static_cast<unsigned char>(arg[0])) == 0) ||
|
||||
strlen(arg) >= 3 || atoi(&arg[0]) == 0 ||
|
||||
(unsigned int)atoi(&arg[0]) > info.cpu_count) {
|
||||
static_cast<unsigned int>(atoi(&arg[0])) > info.cpu_count) {
|
||||
obj->data.i = 1;
|
||||
/* NORM_ERR("freq_g: Invalid CPU number or you don't have that many "
|
||||
"CPUs! Displaying the clock for CPU 1."); */
|
||||
@ -1451,9 +1451,10 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
||||
obj->callbacks.print = &print_totalup;
|
||||
END OBJ(updates, nullptr) obj->callbacks.print = &print_updates;
|
||||
END OBJ_IF(if_updatenr, nullptr) obj->data.i = arg != nullptr ? atoi(arg) : 0;
|
||||
if (obj->data.i == 0)
|
||||
if (obj->data.i == 0) {
|
||||
CRIT_ERR(obj, free_at_crash,
|
||||
"if_updatenr needs a number above 0 as argument");
|
||||
}
|
||||
set_updatereset(obj->data.i > get_updatereset() ? obj->data.i
|
||||
: get_updatereset());
|
||||
obj->callbacks.iftest = &updatenr_iftest;
|
||||
@ -2063,8 +2064,8 @@ int extract_variable_text_internal(struct text_object *retval,
|
||||
} else {
|
||||
s = p;
|
||||
if (*p == '#') { p++; }
|
||||
while ((*p != 0) &&
|
||||
((isalnum((unsigned char)(*p)) != 0) || *p == '_')) {
|
||||
while ((*p != 0) && ((isalnum(static_cast<unsigned char>(*p)) != 0) ||
|
||||
*p == '_')) {
|
||||
p++;
|
||||
}
|
||||
}
|
||||
@ -2098,14 +2099,14 @@ int extract_variable_text_internal(struct text_object *retval,
|
||||
arg = strchr(buf, ' ');
|
||||
*arg = '\0';
|
||||
arg++;
|
||||
while (isspace((unsigned char)(*arg)) != 0) { arg++; }
|
||||
while (isspace(static_cast<unsigned char>(*arg)) != 0) { arg++; }
|
||||
if (*arg == 0) { arg = nullptr; }
|
||||
}
|
||||
|
||||
/* lowercase variable name */
|
||||
tmp_p = buf;
|
||||
while (*tmp_p != 0) {
|
||||
*tmp_p = tolower((unsigned char)*tmp_p);
|
||||
*tmp_p = tolower(static_cast<unsigned char>(*tmp_p));
|
||||
tmp_p++;
|
||||
}
|
||||
|
||||
|
10
src/cpu.cc
10
src/cpu.cc
@ -66,7 +66,10 @@ uint8_t has_tsc_reg(void) {
|
||||
|
||||
CPU_REGS(0x00000000, vend, leafs);
|
||||
if (0x00000001 > leafs) { return 1U; }
|
||||
if ((uint32_t)vend != AmD && (uint32_t)vend != InteL) { return 1U; }
|
||||
if (static_cast<uint32_t>(vend) != AmD &&
|
||||
static_cast<uint32_t>(vend) != InteL) {
|
||||
return 1U;
|
||||
}
|
||||
|
||||
CPU_STR2(0x00000001, eax, ebx, ecx, edx);
|
||||
if (0U == (edx & (1U << 4U))) { return 1U; }
|
||||
@ -90,7 +93,7 @@ uintmax_t rdtsc(void) {
|
||||
: "=a"(ticklo), "=d"(tickhi)::"%rbx", "%rcx");
|
||||
|
||||
CPU_FEATURE(0x80000000, regz);
|
||||
if (0x80000001 > (uint32_t)regz) { goto seeya; }
|
||||
if (0x80000001 > static_cast<uint32_t>(regz)) { goto seeya; }
|
||||
CPU_STR2(0x80000001, eax, ebx, ecx, edx);
|
||||
|
||||
if (0U != (edx & (1U << 27U))) {
|
||||
@ -105,7 +108,8 @@ uintmax_t rdtsc(void) {
|
||||
}
|
||||
|
||||
seeya:
|
||||
return (((uintmax_t)tickhi << 32) | (uintmax_t)ticklo);
|
||||
return ((static_cast<uintmax_t>(tickhi) << 32) |
|
||||
static_cast<uintmax_t>(ticklo));
|
||||
}
|
||||
|
||||
void get_cpu_clock_speed(char *str1, unsigned int p_max_size) {
|
||||
|
@ -46,7 +46,7 @@ class data_source_base {
|
||||
public:
|
||||
const std::string name;
|
||||
|
||||
data_source_base(const std::string &name_) : name(name_) {}
|
||||
explicit data_source_base(const std::string &name_) : name(name_) {}
|
||||
|
||||
virtual ~data_source_base() {}
|
||||
virtual double get_number() const;
|
||||
@ -113,7 +113,7 @@ class register_data_source {
|
||||
|
||||
public:
|
||||
template <typename... Args>
|
||||
register_data_source(const std::string &name, Args &&... args) {
|
||||
explicit register_data_source(const std::string &name, Args &&... args) {
|
||||
priv::do_register_data_source(
|
||||
name,
|
||||
std::bind(&factory<Args...>, std::placeholders::_1, name, args...));
|
||||
|
@ -93,12 +93,12 @@ void print_password(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||
static const char letters[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@#$%^&*("
|
||||
")_";
|
||||
static const int len = (int)sizeof(letters) - 1;
|
||||
static const int len = static_cast<int>(sizeof(letters)) - 1;
|
||||
uintmax_t x = strtoumax(obj->data.s, (char **)NULL, 10);
|
||||
uintmax_t z = 0;
|
||||
|
||||
if (-1 == (t = time(NULL))) { return; }
|
||||
srandom((unsigned int)t);
|
||||
srandom(static_cast<unsigned int>(t));
|
||||
|
||||
for (; z < x && p_max_size - 1 > z; z++) { *p++ = letters[random() % len]; }
|
||||
*p = '\0';
|
||||
|
@ -264,7 +264,7 @@ void scan_exec_arg(struct text_object *obj, const char *arg,
|
||||
|
||||
/* set cmd to everything after the interval */
|
||||
cmd = strndup(arg + n, text_buffer_size.get(*state));
|
||||
orig_cmd = (char *)cmd;
|
||||
orig_cmd = const_cast<char *>(cmd);
|
||||
}
|
||||
|
||||
/* parse any special options for the graphical exec types */
|
||||
|
@ -218,7 +218,7 @@ 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((unsigned char)*arg) != 0) { arg++; }
|
||||
while (isspace(static_cast<unsigned char>(*arg)) != 0) { arg++; }
|
||||
if (*arg == '\0') { arg = "/"; }
|
||||
} else {
|
||||
arg = "/";
|
||||
|
@ -1879,7 +1879,7 @@ void mpd_startFieldSearch(mpd_Connection *connection, int type) {
|
||||
connection->request = static_cast<char *>(malloc(len));
|
||||
|
||||
snprintf(connection->request, len, "list %c%s",
|
||||
tolower((unsigned char)strtype[0]), strtype + 1);
|
||||
tolower(static_cast<unsigned char>(strtype[0])), strtype + 1);
|
||||
}
|
||||
|
||||
void mpd_addConstraintSearch(mpd_Connection *connection, int type,
|
||||
@ -1916,7 +1916,7 @@ void mpd_addConstraintSearch(mpd_Connection *connection, int type,
|
||||
len = strlen(string) + 1 + strlen(strtype) + 2 + strlen(arg) + 2;
|
||||
connection->request = static_cast<char *>(realloc(connection->request, len));
|
||||
snprintf(connection->request, len, "%s %c%s \"%s\"", string,
|
||||
tolower((unsigned char)strtype[0]), strtype + 1, arg);
|
||||
tolower(static_cast<unsigned char>(strtype[0])), strtype + 1, arg);
|
||||
|
||||
free(string);
|
||||
free(arg);
|
||||
|
@ -212,11 +212,13 @@ void llua_load(const char *script) {
|
||||
static const char *tokenize(const char *str, size_t *len) {
|
||||
str += *len;
|
||||
*len = 0;
|
||||
while ((str != nullptr) && (isspace((unsigned char)*str) != 0)) { ++str; }
|
||||
while ((str != nullptr) && (isspace(static_cast<unsigned char>(*str)) != 0)) {
|
||||
++str;
|
||||
}
|
||||
|
||||
size_t level = 0;
|
||||
while ((str != nullptr) && (str[*len] != 0) &&
|
||||
(level > 0 || (isspace((unsigned char)str[*len]) == 0))) {
|
||||
(level > 0 || (isspace(static_cast<unsigned char>(str[*len])) == 0))) {
|
||||
switch (str[*len]) {
|
||||
case '{':
|
||||
++level;
|
||||
|
@ -111,7 +111,7 @@ class syntax_error : public lua::exception {
|
||||
const syntax_error &operator=(const syntax_error &) = delete;
|
||||
|
||||
public:
|
||||
syntax_error(state *L) : lua::exception(L) {}
|
||||
explicit syntax_error(state *L) : lua::exception(L) {}
|
||||
|
||||
syntax_error(syntax_error &&other) : lua::exception(std::move(other)) {}
|
||||
};
|
||||
@ -122,7 +122,7 @@ class file_error : public lua::exception {
|
||||
const file_error &operator=(const file_error &) = delete;
|
||||
|
||||
public:
|
||||
file_error(state *L) : lua::exception(L) {}
|
||||
explicit file_error(state *L) : lua::exception(L) {}
|
||||
|
||||
file_error(file_error &&other) : lua::exception(std::move(other)) {}
|
||||
};
|
||||
@ -134,7 +134,7 @@ class errfunc_error : public lua::exception {
|
||||
const errfunc_error &operator=(const errfunc_error &) = delete;
|
||||
|
||||
public:
|
||||
errfunc_error(state *L) : lua::exception(L) {}
|
||||
explicit errfunc_error(state *L) : lua::exception(L) {}
|
||||
|
||||
errfunc_error(errfunc_error &&other) : lua::exception(std::move(other)) {}
|
||||
};
|
||||
|
@ -281,10 +281,11 @@ int main(int argc, char **argv) {
|
||||
#ifdef BUILD_CURL
|
||||
struct curl_global_initializer {
|
||||
curl_global_initializer() {
|
||||
if (curl_global_init(CURL_GLOBAL_ALL))
|
||||
if (curl_global_init(CURL_GLOBAL_ALL)) {
|
||||
NORM_ERR(
|
||||
"curl_global_init() failed, you may not be able to use curl "
|
||||
"variables");
|
||||
}
|
||||
}
|
||||
~curl_global_initializer() { curl_global_cleanup(); }
|
||||
};
|
||||
@ -314,8 +315,9 @@ int main(int argc, char **argv) {
|
||||
current_config = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
if (freopen("/dev/null", "w", stderr) == nullptr)
|
||||
if (freopen("/dev/null", "w", stderr) == nullptr) {
|
||||
CRIT_ERR(nullptr, nullptr, "could not open /dev/null as stderr!");
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
print_help(argv[0]);
|
||||
|
@ -97,7 +97,7 @@ void print_cap(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||
|
||||
for (; *src && p_max_size - 1 > x; src++, x++) {
|
||||
if (0 == z) {
|
||||
*dest++ = (toupper((unsigned char)*src));
|
||||
*dest++ = (toupper(static_cast<unsigned char>(*src)));
|
||||
z++;
|
||||
continue;
|
||||
}
|
||||
|
@ -357,7 +357,9 @@ void print_mpd_smart(struct text_object *obj, char *p,
|
||||
unsigned int p_max_size) {
|
||||
const mpd_result &mpd_info = get_mpd();
|
||||
int len = obj->data.i;
|
||||
if (len == 0 || (unsigned int)len > p_max_size) { len = p_max_size; }
|
||||
if (len == 0 || static_cast<unsigned int>(len) > p_max_size) {
|
||||
len = p_max_size;
|
||||
}
|
||||
|
||||
memset(p, 0, p_max_size);
|
||||
if ((static_cast<unsigned int>(!mpd_info.artist.empty()) != 0u) &&
|
||||
|
@ -125,7 +125,7 @@ void parse_net_stat_arg(struct text_object *obj, const char *arg,
|
||||
struct net_stat *netstat = nullptr;
|
||||
long int x = 0;
|
||||
unsigned int found = 0;
|
||||
char *arg_ptr = (char *)arg;
|
||||
char *arg_ptr = const_cast<char *>(arg);
|
||||
char buf[64];
|
||||
char *buf_ptr = buf;
|
||||
|
||||
@ -138,7 +138,7 @@ void parse_net_stat_arg(struct text_object *obj, const char *arg,
|
||||
if (0 == strncmp(arg, "${iface", 7)) {
|
||||
if (nullptr != arg_ptr) {
|
||||
for (; *arg_ptr; arg_ptr++) {
|
||||
if (isdigit((unsigned char)*arg_ptr)) {
|
||||
if (isdigit(static_cast<unsigned char>(*arg_ptr))) {
|
||||
*buf_ptr++ = *arg_ptr;
|
||||
found = 1;
|
||||
}
|
||||
@ -165,7 +165,8 @@ void parse_net_stat_arg(struct text_object *obj, const char *arg,
|
||||
netstat = get_net_stat(nextarg, obj, free_at_crash);
|
||||
}
|
||||
i += strlen(nextarg); // skip this arg
|
||||
while (!((isspace((unsigned char)arg[i]) != 0) || arg[i] == 0)) {
|
||||
while (
|
||||
!((isspace(static_cast<unsigned char>(arg[i])) != 0) || arg[i] == 0)) {
|
||||
i++; // and skip the spaces in front of it
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,9 @@ void print_pid_environ(struct text_object *obj, char *p,
|
||||
|
||||
generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub);
|
||||
if (sscanf(objbuf.get(), "%d %s", &pid, var) == 2) {
|
||||
for (i = 0; var[i] != 0; i++) { var[i] = toupper((unsigned char)var[i]); }
|
||||
for (i = 0; var[i] != 0; i++) {
|
||||
var[i] = toupper(static_cast<unsigned char>(var[i]));
|
||||
}
|
||||
pathstream << PROCDIR "/" << pid << "/cwd";
|
||||
buf = readfile(pathstream.str().c_str(), &total_read, 1);
|
||||
if (buf != nullptr) {
|
||||
@ -682,10 +684,11 @@ void print_pid_Xid(struct text_object *obj, char *p, int p_max_size,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (type == fsgid || type == fsuid)
|
||||
if (type == fsgid || type == fsuid) {
|
||||
end = strchr(begin, '\n');
|
||||
else
|
||||
} else {
|
||||
end = strchr(begin, '\t');
|
||||
}
|
||||
if (end != nullptr) { *(end) = 0; }
|
||||
snprintf(p, p_max_size, "%s", begin);
|
||||
} else {
|
||||
|
@ -64,9 +64,10 @@ void parse_read_tcpip_arg(struct text_object *obj, const char *arg,
|
||||
rtd->port = atoi(rtd->host);
|
||||
strncpy(rtd->host, "localhost", 10);
|
||||
}
|
||||
if (rtd->port < 1 || rtd->port > 65535)
|
||||
if (rtd->port < 1 || rtd->port > 65535) {
|
||||
CRIT_ERR(obj, free_at_crash,
|
||||
"read_tcp and read_udp need a port from 1 to 65535 as argument");
|
||||
}
|
||||
|
||||
obj->data.opaque = rtd;
|
||||
}
|
||||
|
@ -107,12 +107,13 @@ static void scroll_scroll_left(struct scroll_data *sd,
|
||||
const std::vector<char> &buf,
|
||||
unsigned int amount) {
|
||||
for (unsigned int i = 0; (i < amount) && (buf[sd->start] != '\0') &&
|
||||
((unsigned int)sd->start < buf.size());
|
||||
(static_cast<unsigned int>(sd->start) < buf.size());
|
||||
++i) {
|
||||
sd->start += scroll_character_length(buf[sd->start]);
|
||||
}
|
||||
|
||||
if (buf[sd->start] == 0 || (unsigned int)sd->start > strlen(buf.data())) {
|
||||
if (buf[sd->start] == 0 ||
|
||||
static_cast<unsigned int>(sd->start) > strlen(buf.data())) {
|
||||
sd->start = 0;
|
||||
}
|
||||
}
|
||||
@ -233,7 +234,9 @@ void print_scroll(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||
}
|
||||
// if length of text changed to shorter so the (sd->start) is already
|
||||
// outside of actual text then reset (sd->start)
|
||||
if ((unsigned int)sd->start >= strlen(&(buf[0]))) { sd->start = 0; }
|
||||
if (static_cast<unsigned int>(sd->start) >= strlen(&(buf[0]))) {
|
||||
sd->start = 0;
|
||||
}
|
||||
// make sure a colorchange at the front is not part of the string we are going
|
||||
// to show
|
||||
while (buf[sd->start] == SPECIAL_CHAR) { sd->start++; }
|
||||
|
@ -45,7 +45,7 @@ class semaphore {
|
||||
semaphore &operator=(const semaphore &) = delete;
|
||||
|
||||
public:
|
||||
semaphore(unsigned int value = 0) {
|
||||
explicit semaphore(unsigned int value = 0) {
|
||||
sem = dispatch_semaphore_create(value);
|
||||
|
||||
if (!sem) throw std::logic_error(strerror(errno));
|
||||
@ -63,10 +63,11 @@ class semaphore {
|
||||
int ret = dispatch_semaphore_wait(sem, DISPATCH_TIME_NOW);
|
||||
|
||||
while (ret > 0) {
|
||||
if (ret == DISPATCH_EAGAIN)
|
||||
if (ret == DISPATCH_EAGAIN) {
|
||||
return false;
|
||||
else if (errno != EINTR)
|
||||
} else if (errno != EINTR) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -244,9 +244,15 @@ class simple_config_setting : public config_setting_template<T> {
|
||||
typedef config_setting_template<T> Base;
|
||||
|
||||
public:
|
||||
simple_config_setting(const std::string &name_, const T &default_value_ = T(),
|
||||
bool modifiable_ = false)
|
||||
explicit simple_config_setting(const std::string &name_,
|
||||
const T &default_value_ = T(),
|
||||
bool modifiable_ = false)
|
||||
: Base(name_), default_value(default_value_), modifiable(modifiable_) {}
|
||||
simple_config_setting(const char *name_, const T &default_value_ = T(),
|
||||
bool modifiable_ = false)
|
||||
: Base(std::string(name_)),
|
||||
default_value(default_value_),
|
||||
modifiable(modifiable_) {}
|
||||
|
||||
protected:
|
||||
const T default_value;
|
||||
@ -295,10 +301,11 @@ void simple_config_setting<T, Traits>::lua_setter(lua::state &l, bool init) {
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (ok && do_convert(l, -2).second)
|
||||
if (ok && do_convert(l, -2).second) {
|
||||
l.pop();
|
||||
else
|
||||
} else {
|
||||
l.replace(-2);
|
||||
}
|
||||
++s;
|
||||
}
|
||||
|
||||
@ -329,10 +336,11 @@ class range_config_setting : public simple_config_setting<T, Traits> {
|
||||
const T max;
|
||||
|
||||
public:
|
||||
range_config_setting(const std::string &name_,
|
||||
const T &min_ = std::numeric_limits<T>::min(),
|
||||
const T &max_ = std::numeric_limits<T>::max(),
|
||||
const T &default_value_ = T(), bool modifiable_ = false)
|
||||
explicit range_config_setting(const std::string &name_,
|
||||
const T &min_ = std::numeric_limits<T>::min(),
|
||||
const T &max_ = std::numeric_limits<T>::max(),
|
||||
const T &default_value_ = T(),
|
||||
bool modifiable_ = false)
|
||||
: Base(name_, default_value_, modifiable_), min(min_), max(max_) {
|
||||
assert(min <= Base::default_value && Base::default_value <= max);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ static void print_tailhead(const char *type, struct text_object *obj, char *p,
|
||||
endofstring = strlen(p);
|
||||
}
|
||||
} else if (strcmp(type, "tail") == 0) {
|
||||
fseek(fp, -(long)p_max_size, SEEK_END);
|
||||
fseek(fp, -static_cast<long>(p_max_size), SEEK_END);
|
||||
i = fread(p, 1, p_max_size - 1, fp);
|
||||
tailstring(p, i, ht->wantedlines);
|
||||
} else {
|
||||
@ -231,7 +231,7 @@ void print_words(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||
words = 0;
|
||||
while (fgets(buf, BUFSZ, fp) != nullptr) {
|
||||
for (j = 0; buf[j] != 0; j++) {
|
||||
if (isspace((unsigned char)buf[j]) == 0) {
|
||||
if (isspace(static_cast<unsigned char>(buf[j])) == 0) {
|
||||
if (inword == 0) {
|
||||
words++;
|
||||
inword = 1;
|
||||
|
@ -76,10 +76,11 @@ static char *backslash_escape(const char *src, char **templates,
|
||||
(tmpl_num > template_count)) {
|
||||
break;
|
||||
}
|
||||
if (tmpl_num == 0)
|
||||
if (tmpl_num == 0) {
|
||||
CRIT_ERR(
|
||||
nullptr, nullptr,
|
||||
"invalid template argument \\0; arguments must start at \\1");
|
||||
}
|
||||
dup_len += strlen(templates[tmpl_num - 1]);
|
||||
src_dup =
|
||||
static_cast<char *>(realloc(src_dup, dup_len * sizeof(char)));
|
||||
@ -184,8 +185,8 @@ char *find_and_replace_templates(const char *inbuf) {
|
||||
if (*(p + 1) == '{') {
|
||||
p += 2;
|
||||
templ = p;
|
||||
while ((*p != 0) && (isspace((unsigned char)*p) == 0) && *p != '{' &&
|
||||
*p != '}') {
|
||||
while ((*p != 0) && (isspace(static_cast<unsigned char>(*p)) == 0) &&
|
||||
*p != '{' && *p != '}') {
|
||||
p++;
|
||||
}
|
||||
if (*p == '}') {
|
||||
@ -214,7 +215,9 @@ char *find_and_replace_templates(const char *inbuf) {
|
||||
} else {
|
||||
templ = p + 1;
|
||||
p += strlen("$template");
|
||||
while ((*p != 0) && (isdigit((unsigned char)*p) != 0)) { p++; }
|
||||
while ((*p != 0) && (isdigit(static_cast<unsigned char>(*p)) != 0)) {
|
||||
p++;
|
||||
}
|
||||
args = nullptr;
|
||||
}
|
||||
tmpl_out = handle_template(templ, args);
|
||||
|
@ -72,8 +72,9 @@ int append_object(struct text_object *root, struct text_object *obj) {
|
||||
|
||||
/* update pointers of the list to append to */
|
||||
if (end != nullptr) {
|
||||
if (end->next != nullptr)
|
||||
if (end->next != nullptr) {
|
||||
CRIT_ERR(nullptr, nullptr, "huston, we have a lift-off");
|
||||
}
|
||||
end->next = obj;
|
||||
} else {
|
||||
root->next = obj;
|
||||
@ -122,8 +123,9 @@ static int push_ifblock(struct ifblock_stack_obj **ifblock_stack_top,
|
||||
|
||||
switch (type) {
|
||||
case IFBLOCK_ENDIF:
|
||||
if ((*ifblock_stack_top) == nullptr)
|
||||
if ((*ifblock_stack_top) == nullptr) {
|
||||
CRIT_ERR(nullptr, nullptr, "got an endif without matching if");
|
||||
}
|
||||
(*ifblock_stack_top)->obj->ifblock_next = obj;
|
||||
/* if there's some else in between, remove and free it */
|
||||
if ((*ifblock_stack_top)->type == IFBLOCK_ELSE) {
|
||||
@ -137,8 +139,9 @@ static int push_ifblock(struct ifblock_stack_obj **ifblock_stack_top,
|
||||
free(stackobj);
|
||||
break;
|
||||
case IFBLOCK_ELSE:
|
||||
if ((*ifblock_stack_top) == nullptr)
|
||||
if ((*ifblock_stack_top) == nullptr) {
|
||||
CRIT_ERR(nullptr, nullptr, "got an else without matching if");
|
||||
}
|
||||
(*ifblock_stack_top)->obj->ifblock_next = obj;
|
||||
/* falls through */
|
||||
case IFBLOCK_IF:
|
||||
|
@ -464,7 +464,8 @@ static void print_top_name(struct text_object *obj, char *p,
|
||||
return;
|
||||
}
|
||||
|
||||
width = std::min(p_max_size, (unsigned int)top_name_width.get(*state) + 1);
|
||||
width = std::min(p_max_size,
|
||||
static_cast<unsigned int>(top_name_width.get(*state)) + 1);
|
||||
if (top_name_verbose.get(*state)) {
|
||||
/* print the full command line */
|
||||
snprintf(p, width + 1, "%-*s", width, td->list[td->num]->name);
|
||||
@ -484,7 +485,7 @@ static void print_top_mem(struct text_object *obj, char *p,
|
||||
return;
|
||||
}
|
||||
|
||||
width = std::min(p_max_size, (unsigned int)7);
|
||||
width = std::min(p_max_size, static_cast<unsigned int>(7));
|
||||
snprintf(p, width, "%6.2f",
|
||||
(static_cast<float>(td->list[td->num]->rss) / info.memmax) / 10);
|
||||
}
|
||||
@ -500,7 +501,7 @@ static void print_top_time(struct text_object *obj, char *p,
|
||||
return;
|
||||
}
|
||||
|
||||
width = std::min(p_max_size, (unsigned int)10);
|
||||
width = std::min(p_max_size, static_cast<unsigned int>(10));
|
||||
timeval = format_time(td->list[td->num]->total_cpu_time, 9);
|
||||
snprintf(p, width, "%9s", timeval);
|
||||
free(timeval);
|
||||
|
@ -383,9 +383,9 @@ x11_error_handler(Display *d, XErrorEvent *err) {
|
||||
NORM_ERR(
|
||||
"X Error: type %i Display %lx XID %li serial %lu error_code %i "
|
||||
"request_code %i minor_code %i other Display: %lx\n",
|
||||
err->type, (long unsigned)err->display, (long)err->resourceid,
|
||||
err->serial, err->error_code, err->request_code, err->minor_code,
|
||||
(long unsigned)d);
|
||||
err->type, (long unsigned)err->display,
|
||||
static_cast<long>(err->resourceid), err->serial, err->error_code,
|
||||
err->request_code, err->minor_code, (long unsigned)d);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user