1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-10-01 14:39:13 +00:00

More build fixes.

This commit is contained in:
Brenden Matthews 2018-12-22 16:16:28 -05:00
parent 50a4aa25ab
commit bc60fb2c2f
No known key found for this signature in database
GPG Key ID: 60FBD122E62B0D30
16 changed files with 180 additions and 136 deletions

View File

@ -317,9 +317,12 @@ before_script:
fi
script:
- cd build
- if [ "$CXX" = "clang++-7" ] ; then build-wrapper-linux-x86-64 --out-dir bw-output make -j4 ; fi
- if [ "$CXX" = "g++-8" ] ; then make -j4 ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make -j4 ; fi
- |
if [ "$CXX" = "clang++-7" ] ; then
build-wrapper-linux-x86-64 --out-dir bw-output make -j4 ;
else
make -j4 ;
fi
- cd ../build-no-x11
- make -j4
- cd ..
@ -331,4 +334,4 @@ sudo: false
cache:
- ccache: true
- directories:
- '$HOME/.sonar/cache'
- "$HOME/.sonar/cache"

View File

@ -157,3 +157,27 @@ macro(AC_SEARCH_LIBS FUNCTION_NAME INCLUDES TARGET_VAR)
endif(${AC_SEARCH_LIBS_TMP})
endif("${TARGET_VAR}" MATCHES "^${TARGET_VAR}$")
endmacro(AC_SEARCH_LIBS)
# A function to print the target build properties
function(print_target_properties tgt)
if(NOT TARGET ${tgt})
message("There is no target named '${tgt}'")
return()
endif()
# this list of properties can be extended as needed
set(CMAKE_PROPERTY_LIST SOURCE_DIR BINARY_DIR COMPILE_DEFINITIONS
COMPILE_OPTIONS INCLUDE_DIRECTORIES LINK_LIBRARIES)
message("Configuration for target ${tgt}")
foreach (prop ${CMAKE_PROPERTY_LIST})
get_property(propval TARGET ${tgt} PROPERTY ${prop} SET)
if (propval)
get_target_property(propval ${tgt} ${prop})
message (STATUS "${prop} = ${propval}")
endif()
endforeach(prop)
endfunction(print_target_properties)

View File

@ -32,15 +32,21 @@ if(NOT CMAKE_BUILD_TYPE)
endif(NOT CMAKE_BUILD_TYPE)
# -std options for all build types
set(CMAKE_C_FLAGS "-std=c99" CACHE STRING "Flags used by the C compiler during all build types.")
set(CMAKE_CXX_FLAGS "-std=c++17" CACHE STRING "Flags used by the C++ compiler during all build types.")
set(CMAKE_C_FLAGS "-std=c99" CACHE STRING "Flags used by the C compiler during all build types." FORCE)
set(CMAKE_CXX_FLAGS "-std=c++17" CACHE STRING "Flags used by the C++ compiler during all build types." FORCE)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(MAINTAINER_MODE)
# some extra debug flags when in 'maintainer mode'
set(CMAKE_C_FLAGS_DEBUG "-ggdb -Wall -W -Wextra -Wunused -Wdeclaration-after-statement -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wold-style-definition -Winline -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -pedantic -Werror ${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -Wall -W -Wextra -Wunused -pedantic -Werror -Wno-format ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
# Some flags are only supported on GCC >= 7.0, such as -Wimplicit-fallthrough=2
set(CMAKE_C_FLAGS_DEBUG "-ggdb -Wall -W -Wextra -Wunused -Wdeclaration-after-statement -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wold-style-definition -Winline -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -pedantic -Werror ${CMAKE_C_FLAGS_DEBUG} -Wno-unknown-pragmas -Wno-error=pragmas -Wimplicit-fallthrough=2" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -Wall -W -Wextra -Wunused -pedantic -Werror -Wno-format ${CMAKE_CXX_FLAGS_DEBUG} -Wno-unknown-pragmas -Wno-error=pragmas -Wimplicit-fallthrough=2" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
else()
set(CMAKE_C_FLAGS_DEBUG "-ggdb -Wall -W -Wextra -Wunused -Wdeclaration-after-statement -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wold-style-definition -Winline -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -pedantic -Werror ${CMAKE_C_FLAGS_DEBUG} -Wno-unknown-pragmas -Wno-error=pragmas" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -Wall -W -Wextra -Wunused -pedantic -Werror -Wno-format ${CMAKE_CXX_FLAGS_DEBUG} -Wno-unknown-pragmas -Wno-error=pragmas" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
endif()
endif(MAINTAINER_MODE)
option(CHECK_CODE_QUALITY "Check code formatting/quality with clang" false)
@ -195,3 +201,20 @@ option(BUILD_CMUS "Enable support for cmus music player" true)
option(BUILD_JOURNAL "Enable support for reading from the systemd journal" false)
option(BUILD_PULSEAUDIO "Enable support for Pulseaudio's default sink and source" false)
message( STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS} )
message( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} )
message( STATUS "CMAKE_C_FLAGS_DEBUG: " ${CMAKE_C_FLAGS_DEBUG} )
message( STATUS "CMAKE_CXX_FLAGS_DEBUG: " ${CMAKE_CXX_FLAGS_DEBUG} )
message( STATUS "CMAKE_C_FLAGS_MINSIZEREL: " ${CMAKE_C_FLAGS_MINSIZEREL} )
message( STATUS "CMAKE_CXX_FLAGS_MINSIZEREL: " ${CMAKE_CXX_FLAGS_MINSIZEREL} )
message( STATUS "CMAKE_C_FLAGS_RELEASE: " ${CMAKE_C_FLAGS_RELEASE} )
message( STATUS "CMAKE_CXX_FLAGS_RELEASE: " ${CMAKE_CXX_FLAGS_RELEASE} )
message( STATUS "CMAKE_C_FLAGS_RELWITHDEBINFO: " ${CMAKE_C_FLAGS_RELWITHDEBINFO} )
message( STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO: " ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} )
message( STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} )

View File

@ -74,10 +74,10 @@ if(MAINTAINER_MODE)
COMMAND ${APP_DB2X_MANXML} --encoding=utf-8 ${FIL}.mxml --output-dir ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${APP_XSLTPROC} ${CMAKE_SOURCE_DIR}/doc/docbook-xml/html/docbook.xsl ${CMAKE_CURRENT_SOURCE_DIR}/${FIL}.xml > ${CMAKE_CURRENT_SOURCE_DIR}/${FIL}.html
COMMAND ${APP_MAN} -P '${APP_LESS} -is' ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.1 > ${CMAKE_SOURCE_DIR}/README
COMMAND ${APP_SED} -i -e "s/[[:cntrl:]]\\[[0-9]*m//g" ${CMAKE_SOURCE_DIR}/README
COMMAND ${APP_SED} -i -e "s/\\xE2//g" ${CMAKE_SOURCE_DIR}/README
COMMAND ${APP_SED} -i -e "s/\\x80//g" ${CMAKE_SOURCE_DIR}/README
COMMAND ${APP_SED} -i -e "s/\\x90/-/g" ${CMAKE_SOURCE_DIR}/README
COMMAND ${APP_SED} -i'' -e 's/[[:cntrl:]]\\[[0-9]*m//g' ${CMAKE_SOURCE_DIR}/README
COMMAND ${APP_SED} -i'' -e 's/\\xE2//g' ${CMAKE_SOURCE_DIR}/README
COMMAND ${APP_SED} -i'' -e 's/\\x80//g' ${CMAKE_SOURCE_DIR}/README
COMMAND ${APP_SED} -i'' -e 's/\\x90/-/g' ${CMAKE_SOURCE_DIR}/README
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FIL}.xml
COMMENT "Proccessing man page for ${FIL}"
)

View File

@ -50,7 +50,7 @@ ADD_CUSTOM_COMMAND( OUTPUT ${TOLUA_OUT} ${INCL} COMMAND
VERBATIM )
SET_SOURCE_FILES_PROPERTIES(${${VAR}} ${INCL} PROPERTIES GENERATED TRUE)
SET_SOURCE_FILES_PROPERTIES(${${VAR}} PROPERTIES COMPILE_FLAGS "-Wno-bad-function-cast -Wno-unused-parameter -Wno-cast-qual")
SET_SOURCE_FILES_PROPERTIES(${${VAR}} PROPERTIES COMPILE_FLAGS "-Wno-bad-function-cast -Wno-unused-parameter -Wno-cast-qual -Wno-error=pedantic")
SET(${VAR} ${${VAR}} PARENT_SCOPE)

View File

@ -41,6 +41,8 @@ if(BUILD_X11)
target_link_libraries(conky-cairo ${luacairo_libs} toluapp_lib_static)
set(lua_libs ${lua_libs} conky-cairo)
print_target_properties(conky-cairo)
endif(BUILD_LUA_CAIRO)
if(BUILD_LUA_IMLIB2)
@ -52,6 +54,8 @@ if(BUILD_X11)
target_link_libraries(conky-imlib2 ${luaimlib2_libs} toluapp_lib_static)
set(lua_libs ${lua_libs} conky-imlib2)
print_target_properties(conky-imlib2)
endif(BUILD_LUA_IMLIB2)
if(BUILD_LUA_RSVG)
@ -63,6 +67,8 @@ if(BUILD_X11)
target_link_libraries(conky-rsvg ${luarsvg_libs} toluapp_lib_static)
set(lua_libs ${lua_libs} conky-rsvg)
print_target_properties(conky-rsvg)
endif(BUILD_LUA_RSVG)
if(BUILD_LUA_CAIRO AND BUILD_LUA_IMLIB2)

View File

@ -340,3 +340,5 @@ install(TARGETS
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
print_target_properties(conky)

View File

@ -46,10 +46,8 @@ int find_match_op(const char *expr) {
switch (expr[idx]) {
case '=':
case '!':
if (expr[idx + 1] != '=') {
return -1;
}
/* fall through */
if (expr[idx + 1] != '=') { return -1; }
/* falls through */
case '<':
case '>':
return idx;
@ -63,27 +61,17 @@ int get_match_type(const char *expr) {
int idx;
const char *str;
if ((idx = find_match_op(expr)) == -1) {
return -1;
}
if ((idx = find_match_op(expr)) == -1) { return -1; }
str = expr + idx;
if (*str == '=' && *(str + 1) == '=') {
return OP_EQ;
}
if (*str == '!' && *(str + 1) == '=') {
return OP_NEQ;
}
if (*str == '=' && *(str + 1) == '=') { return OP_EQ; }
if (*str == '!' && *(str + 1) == '=') { return OP_NEQ; }
if (*str == '>') {
if (*(str + 1) == '=') {
return OP_GEQ;
}
if (*(str + 1) == '=') { return OP_GEQ; }
return OP_GT;
}
if (*str == '<') {
if (*(str + 1) == '=') {
return OP_LEQ;
}
if (*(str + 1) == '=') { return OP_LEQ; }
return OP_LT;
}
return -1;
@ -132,35 +120,23 @@ enum arg_type get_arg_type(const char *arg) {
p = arg;
e = arg + strlen(arg) - 1;
while (p != e && (*e != 0) && *e == ' ') {
e--;
}
while (p != e && *p == ' ') {
p++;
}
while (p != e && (*e != 0) && *e == ' ') { e--; }
while (p != e && *p == ' ') { p++; }
if (*p == '"' && *e == '"') {
return ARG_STRING;
}
if (*p == '"' && *e == '"') { return ARG_STRING; }
if (*p == '-') { // allow negative values
p++;
}
while (p <= e) {
if (isdigit((unsigned char)*p) == 0) {
break;
}
if (isdigit((unsigned char)*p) == 0) { break; }
p++;
}
if (p == e + 1) {
return ARG_LONG;
}
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((unsigned char)*p) == 0) { return ARG_BAD; }
p++;
}
return ARG_DOUBLE;
@ -174,15 +150,9 @@ char *arg_to_string(const char *arg) {
start = arg;
len = 0;
while ((*start != 0) && *start == ' ') {
start++;
}
if (!(*(start++) == '"')) {
return nullptr;
}
while (start[len] != '"') {
len++;
}
while ((*start != 0) && *start == ' ') { start++; }
if (!(*(start++) == '"')) { return nullptr; }
while (start[len] != '"') { len++; }
return strndup(start, len);
}
double arg_to_double(const char *arg) {
@ -218,9 +188,7 @@ int compare(const char *expr) {
expr_dup = strdup(expr);
expr_dup[idx] = '\0';
if (expr_dup[idx + 1] == '=') {
expr_dup[++idx] = '\0';
}
if (expr_dup[idx + 1] == '=') { expr_dup[++idx] = '\0'; }
type1 = get_arg_type(expr_dup);
type2 = get_arg_type(expr_dup + idx + 1);
@ -229,12 +197,8 @@ int compare(const char *expr) {
free(expr_dup);
return -2;
}
if (type1 == ARG_LONG && type2 == ARG_DOUBLE) {
type1 = ARG_DOUBLE;
}
if (type1 == ARG_DOUBLE && type2 == ARG_LONG) {
type2 = ARG_DOUBLE;
}
if (type1 == ARG_LONG && type2 == ARG_DOUBLE) { type1 = ARG_DOUBLE; }
if (type1 == ARG_DOUBLE && type2 == ARG_LONG) { type2 = ARG_DOUBLE; }
if (type1 != type2) {
NORM_ERR("trying to compare args '%s' and '%s' of different type", expr_dup,
(expr_dup + idx + 1));

View File

@ -42,10 +42,10 @@ struct diskio_stat {
last(UINT_MAX),
last_read(UINT_MAX),
last_write(UINT_MAX) {
std::memset(sample, 0, sizeof(sample) / sizeof(sample[0]));
std::memset(sample_read, 0, sizeof(sample_read) / sizeof(sample_read[0]));
std::memset(sample, 0, sizeof(sample[0]) * sizeof(sample));
std::memset(sample_read, 0, sizeof(sample_read[0]) * sizeof(sample_read));
std::memset(sample_write, 0,
sizeof(sample_write) / sizeof(sample_write[0]));
sizeof(sample_write[0]) * sizeof(sample_write));
}
struct diskio_stat *next;
char *dev;

View File

@ -53,6 +53,12 @@ struct hdd_info {
char *dev;
short temp;
char unit;
void reset() {
next = 0;
dev = 0;
temp = 0;
unit = 0;
}
};
struct hdd_info hdd_info_head;
@ -77,7 +83,7 @@ static void add_hddtemp_info(char *dev, short temp, char unit) {
while (hdi->next) hdi = hdi->next;
hdi->next = new hdd_info;
memset(hdi->next, 0, sizeof(struct hdd_info));
hdi->next->reset();
hdi->next->dev = strdup(dev);
hdi->next->temp = temp;
hdi->next->unit = unit;

View File

@ -27,16 +27,16 @@
*
*/
#include "net_stat.h"
#include <ctype.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <cerrno>
#include <cstring>
#include <string.h>
#include <ctype.h>
#include "conky.h"
#include "logging.h"
#include "net/if.h"
#include "net_stat.h"
#include "specials.h"
#include "text_object.h"
#if defined(__sun)
@ -131,8 +131,7 @@ void parse_net_stat_arg(struct text_object *obj, const char *arg,
if (arg == nullptr) { arg = DEFAULTNETDEV; }
if (0 == (strcmp("$gw_iface", arg)) ||
0 == (strcmp("${gw_iface}", arg))) {
if (0 == (strcmp("$gw_iface", arg)) || 0 == (strcmp("${gw_iface}", arg))) {
arg = e_iface;
}
@ -148,9 +147,7 @@ void parse_net_stat_arg(struct text_object *obj, const char *arg,
if (1U == found) {
*buf_ptr = '\0';
x = strtol(buf, (char **)NULL, 10);
if (63L > x) {
arg = interfaces_arr[x];
}
if (63L > x) { arg = interfaces_arr[x]; }
}
}
@ -196,7 +193,8 @@ void parse_net_stat_bar_arg(struct text_object *obj, const char *arg,
}
}
void print_downspeed(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_downspeed(struct text_object *obj, char *p,
unsigned int p_max_size) {
auto *ns = static_cast<struct net_stat *>(obj->data.opaque);
if (ns == nullptr) { return; }
@ -204,7 +202,8 @@ void print_downspeed(struct text_object *obj, char *p, unsigned int p_max_size)
human_readable(ns->recv_speed, p, p_max_size);
}
void print_downspeedf(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_downspeedf(struct text_object *obj, char *p,
unsigned int p_max_size) {
auto *ns = static_cast<struct net_stat *>(obj->data.opaque);
if (ns == nullptr) { return; }
@ -228,7 +227,8 @@ void print_upspeedf(struct text_object *obj, char *p, unsigned int p_max_size) {
spaced_print(p, p_max_size, "%.1f", 8, ns->trans_speed / 1024.0);
}
void print_totaldown(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_totaldown(struct text_object *obj, char *p,
unsigned int p_max_size) {
auto *ns = static_cast<struct net_stat *>(obj->data.opaque);
if (ns == nullptr) { return; }
@ -355,7 +355,8 @@ double upspeedgraphval(struct text_object *obj) {
#endif /* BUILD_X11 */
#ifdef BUILD_WLAN
void print_wireless_essid(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_wireless_essid(struct text_object *obj, char *p,
unsigned int p_max_size) {
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
if (!ns) {
@ -370,14 +371,16 @@ void print_wireless_essid(struct text_object *obj, char *p, unsigned int p_max_s
snprintf(p, p_max_size, "%s", ns->essid);
}
void print_wireless_mode(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_wireless_mode(struct text_object *obj, char *p,
unsigned int p_max_size) {
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
if (!ns) return;
snprintf(p, p_max_size, "%s", ns->mode);
}
void print_wireless_channel(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_wireless_channel(struct text_object *obj, char *p,
unsigned int p_max_size) {
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
if (!ns) return;
@ -388,7 +391,8 @@ void print_wireless_channel(struct text_object *obj, char *p, unsigned int p_max
snprintf(p, p_max_size, "%s", "/");
}
}
void print_wireless_frequency(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_wireless_frequency(struct text_object *obj, char *p,
unsigned int p_max_size) {
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
if (!ns) return;
@ -399,35 +403,40 @@ void print_wireless_frequency(struct text_object *obj, char *p, unsigned int p_m
snprintf(p, p_max_size, "/");
}
}
void print_wireless_bitrate(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_wireless_bitrate(struct text_object *obj, char *p,
unsigned int p_max_size) {
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
if (!ns) return;
snprintf(p, p_max_size, "%s", ns->bitrate);
}
void print_wireless_ap(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_wireless_ap(struct text_object *obj, char *p,
unsigned int p_max_size) {
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
if (!ns) return;
snprintf(p, p_max_size, "%s", ns->ap);
}
void print_wireless_link_qual(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_wireless_link_qual(struct text_object *obj, char *p,
unsigned int p_max_size) {
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
if (!ns) return;
spaced_print(p, p_max_size, "%d", 4, ns->link_qual);
}
void print_wireless_link_qual_max(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_wireless_link_qual_max(struct text_object *obj, char *p,
unsigned int p_max_size) {
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
if (!ns) return;
spaced_print(p, p_max_size, "%d", 4, ns->link_qual_max);
}
void print_wireless_link_qual_perc(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_wireless_link_qual_perc(struct text_object *obj, char *p,
unsigned int p_max_size) {
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
if (!ns) return;
@ -544,6 +553,10 @@ struct _dns_data {
_dns_data() = default;
int nscount{0};
char **ns_list{nullptr};
void reset() {
nscount = 0;
ns_list = nullptr;
}
};
static _dns_data dns_data;
@ -555,7 +568,7 @@ void free_dns_data(struct text_object *obj) {
for (i = 0; i < dns_data.nscount; i++) { free(dns_data.ns_list[i]); }
free(dns_data.ns_list);
memset(&dns_data, 0, sizeof(dns_data));
dns_data.reset();
}
int update_dns_data() {
@ -591,7 +604,8 @@ void parse_nameserver_arg(struct text_object *obj, const char *arg) {
obj->data.l = arg != nullptr ? atoi(arg) : 0;
}
void print_nameserver(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_nameserver(struct text_object *obj, char *p,
unsigned int p_max_size) {
if (dns_data.nscount > obj->data.l) {
snprintf(p, p_max_size, "%s", dns_data.ns_list[obj->data.l]);
}

View File

@ -179,11 +179,13 @@ void subscribe_cb(pa_context *c, pa_subscription_event_type_t t, uint32_t index,
}
#define PULSEAUDIO_WAIT(COMMAND) \
{ \
op = COMMAND; \
while (pa_operation_get_state(op) == PA_OPERATION_RUNNING) { \
pa_threaded_mainloop_wait(pulseaudio->mainloop); \
} \
pa_operation_unref(op);
pa_operation_unref(op); \
}
void init_pulseaudio(struct text_object *obj) {
// already initialized
@ -219,9 +221,7 @@ void init_pulseaudio(struct text_object *obj) {
}
pa_threaded_mainloop_start(pulseaudio->mainloop);
while (pulseaudio->cstate != PULSE_CONTEXT_READY) {
usleep(200);
}
while (pulseaudio->cstate != PULSE_CONTEXT_READY) { usleep(200); }
// Initial parameters update
@ -324,7 +324,8 @@ void print_puau_card_active_profile(struct text_object *obj, char *p,
get_pulseaudio(obj).card_active_profile_description.c_str());
}
void print_puau_card_name(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_puau_card_name(struct text_object *obj, char *p,
unsigned int p_max_size) {
snprintf(p, p_max_size, "%s", get_pulseaudio(obj).card_name.c_str());
}

View File

@ -37,18 +37,15 @@ void gen_free_opaque(struct text_object *obj) {
free_and_zero(obj->data.opaque);
}
int gen_false_iftest(struct text_object *) {
return 0;
}
int gen_false_iftest(struct text_object *) { return 0; }
void gen_print_nothing(struct text_object *, char *, unsigned int) {
// literally does nothing
}
void gen_print_obj_data_s(struct text_object *obj, char *p, unsigned int p_max_size) {
if (obj->data.s == nullptr) {
return;
}
void gen_print_obj_data_s(struct text_object *obj, char *p,
unsigned int p_max_size) {
if (obj->data.s == nullptr) { return; }
snprintf(p, p_max_size, "%s", obj->data.s);
}
@ -83,9 +80,7 @@ int append_object(struct text_object *root, struct text_object *obj) {
}
/* find end of appended list to point root->prev there */
while (obj->next != nullptr) {
obj = obj->next;
}
while (obj->next != nullptr) { obj = obj->next; }
root->prev = obj;
return 0;
@ -145,7 +140,7 @@ static int push_ifblock(struct ifblock_stack_obj **ifblock_stack_top,
if ((*ifblock_stack_top) == nullptr)
CRIT_ERR(nullptr, nullptr, "got an else without matching if");
(*ifblock_stack_top)->obj->ifblock_next = obj;
/* fall through */
/* falls through */
case IFBLOCK_IF:
stackobj = static_cast<ifblock_stack_obj *>(
malloc(sizeof(struct ifblock_stack_obj)));

View File

@ -62,10 +62,10 @@ void scan_tztime(struct text_object *obj, const char *arg) {
if (arg != nullptr) {
int nArgs = sscanf(arg, "%255s %255[^\n]", buf1, buf2);
switch (nArgs) {
case 2:
if (nArgs == 2) {
fmt = buf2;
case 1:
tz = buf1;
} else if (nArgs == 1) {
tz = buf1;
}
}
@ -312,7 +312,8 @@ static void do_format_time(struct text_object *obj, char *p,
}
}
void print_format_time(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_format_time(struct text_object *obj, char *p,
unsigned int p_max_size) {
std::unique_ptr<char[]> buf(new char[max_user_text.get(*state)]);
generate_text_internal(buf.get(), max_user_text.get(*state), *obj->sub);

View File

@ -40,7 +40,7 @@ static void user_name(char *ptr) {
setutent();
while ((usr = getutent()) != nullptr) {
if (usr->ut_type == USER_PROCESS) {
if (strlen(ptr) + strlen(usr->ut_name) + 1 <= BUFLEN) {
if (strlen(ptr) + strnlen(usr->ut_name, UT_NAMESIZE - 1) + 1 <= BUFLEN) {
strncat(ptr, usr->ut_name, UT_NAMESIZE);
}
}
@ -62,7 +62,7 @@ static void user_term(char *ptr) {
setutent();
while ((usr = getutent()) != nullptr) {
if (usr->ut_type == USER_PROCESS) {
if (strlen(ptr) + strlen(usr->ut_line) + 1 <= BUFLEN) {
if (strlen(ptr) + strnlen(usr->ut_line, UT_LINESIZE) + 1 <= BUFLEN) {
strncat(ptr, usr->ut_line, UT_LINESIZE);
}
}
@ -184,27 +184,32 @@ int update_users(void) {
return 0;
}
void print_user_names(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_user_names(struct text_object *obj, char *p,
unsigned int p_max_size) {
(void)obj;
snprintf(p, p_max_size, "%s", info.users.names);
}
void print_user_terms(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_user_terms(struct text_object *obj, char *p,
unsigned int p_max_size) {
(void)obj;
snprintf(p, p_max_size, "%s", info.users.terms);
}
void print_user_times(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_user_times(struct text_object *obj, char *p,
unsigned int p_max_size) {
(void)obj;
snprintf(p, p_max_size, "%s", info.users.times);
}
void print_user_time(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_user_time(struct text_object *obj, char *p,
unsigned int p_max_size) {
update_user_time(obj->data.s);
snprintf(p, p_max_size, "%s", info.users.ctime);
}
void print_user_number(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_user_number(struct text_object *obj, char *p,
unsigned int p_max_size) {
(void)obj;
snprintf(p, p_max_size, "%d", info.users.number);
}

View File

@ -32,12 +32,12 @@
#include "conky.h"
#include "logging.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-register"
#pragma clang diagnostic ignored "-Wregister"
#pragma clang diagnostic ignored "-Wvariadic-macros"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wvariadic-macros"
#pragma GCC diagnostic ignored "-Wdeprecated-register"
#pragma GCC diagnostic ignored "-Wregister"
#include <X11/XKBlib.h>
#pragma clang diagnostic pop
#pragma GCC diagnostic pop
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xmd.h>
@ -294,7 +294,7 @@ std::pair<uint16_t, bool> window_hints_traits::convert(
#ifdef OWN_WINDOW
namespace {
// used to set the default value for own_window_title
std::string ethostnamecxx() {
std::string gethostnamecxx() {
update_uname();
return info.uname_s.nodename;
}