Skip to content

Commit

Permalink
Upd: Silence clang-tidy 19 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Oct 10, 2024
1 parent 11f7380 commit ddbb299
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Checks: '*,-clang-analyzer-optin.core.EnumCastOutOfRange,-readability-avoid-nested-conditional-operator,-bugprone-switch-missing-default-case,-misc-include-cleaner,-altera-*,-clang-analyzer-optin.performance.Padding,-bugprone-easily-swappable-parameters,-bugprone-assignment-in-if-condition,-clang-diagnostic-invalid-command-line-argument,-concurrency-mt-unsafe,-cppcoreguidelines*,-hicpp-*,-llvmlibc-restrict-system-libc-headers,-readability-identifier-length,-readability-function-cognitive-complexity,-google-readability-function-size,-readability-function-size,-readability-magic-numbers,-readability-non-const-parameter,-google-readability-todo'
Checks: '*,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-optin.core.EnumCastOutOfRange,-readability-avoid-nested-conditional-operator,-bugprone-switch-missing-default-case,-misc-include-cleaner,-altera-*,-clang-analyzer-optin.performance.Padding,-bugprone-easily-swappable-parameters,-bugprone-assignment-in-if-condition,-clang-diagnostic-invalid-command-line-argument,-concurrency-mt-unsafe,-cppcoreguidelines*,-hicpp-*,-llvmlibc-restrict-system-libc-headers,-readability-identifier-length,-readability-function-cognitive-complexity,-google-readability-function-size,-readability-function-size,-readability-magic-numbers,-readability-non-const-parameter,-google-readability-todo'
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: none
Expand Down
2 changes: 1 addition & 1 deletion src/lib/cache_rax_album.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ void album_cache_set_uri(struct mpd_song *album, const char *uri) {
free(album->uri);
size_t len = strlen(uri);
album->uri = malloc_assert(len + 1);
snprintf(album->uri, len, "%s", uri);
(void)snprintf(album->uri, len, "%s", uri);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/lib/datetime.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ time_t parse_date(const char *str) {
*/
void readable_time(char *buf, time_t timestamp) {
if (timestamp == 0) {
snprintf(buf, 2, "0");
buf[0] = '0';
buf[1] = '\0';
}
else {
struct tm *tmp = localtime(&timestamp);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/handle_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static struct option long_options[] = {
* @param cmd argv[0] from main function
*/
static void print_usage(struct t_config *config, const char *cmd) {
fprintf(stderr, "\nUsage: %s [OPTION]...\n\n"
(void)fprintf(stderr, "\nUsage: %s [OPTION]...\n\n"
"myMPD %s\n"
"(c) 2018-2024 Juergen Mang <[email protected]>\n"
"https://github.com/jcorporation/myMPD\n\n"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/msg_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static void set_wait_time(int timeout_ms, struct timespec *max_wait) {
MYMPD_LOG_ERRNO(NULL, errno);
assert(NULL);
}
int64_t timeout_ns = (int64_t)max_wait->tv_nsec + (int64_t)timeout_ms * MSEC_NSEC;
int64_t timeout_ns = (int64_t)max_wait->tv_nsec + ((int64_t)timeout_ms * MSEC_NSEC);
if (timeout_ns > NSEC_MAX) {
max_wait->tv_sec += (time_t)(timeout_ns / SEC_NSEC);
max_wait->tv_nsec = (long)(timeout_ns % SEC_NSEC);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ bool get_ipv6_support(void);
/**
* Start measurement
*/
#define MEASURE_START clock_gettime(CLOCK_MONOTONIC, &tic);
#define MEASURE_START (void)clock_gettime(CLOCK_MONOTONIC, &tic);

/**
* Stop measurement
*/
#define MEASURE_END clock_gettime(CLOCK_MONOTONIC, &toc);
#define MEASURE_END (void)clock_gettime(CLOCK_MONOTONIC, &toc);

/**
* Print measurement result
Expand Down
2 changes: 1 addition & 1 deletion src/mympd_api/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ sds mympd_api_status_get(struct t_partition_state *partition_state, struct t_cac
//scrobble time is half length of song or SCROBBLE_TIME_MAX (4 minutes) whatever is shorter
time_t scrobble_offset = partition_state->song_duration > SCROBBLE_TIME_TOTAL
? SCROBBLE_TIME_MAX - elapsed_time
: partition_state->song_duration / 2 - elapsed_time;
: (partition_state->song_duration / 2) - elapsed_time;
if (scrobble_offset > 0) {
MYMPD_LOG_DEBUG(partition_state->name, "Setting scrobble timer");
mympd_timer_set(partition_state->timer_fd_scrobble, (int)scrobble_offset, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/mympd_api/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ struct t_timer_definition *mympd_api_timer_parse(sds str, const char *partition,
int mympd_api_timer_calc_starttime(int start_hour, int start_minute, int interval) {
time_t now = time(NULL);
struct tm tms;
localtime_r(&now, &tms);
(void)localtime_r(&now, &tms);
tms.tm_hour = start_hour;
tms.tm_min = start_minute;
tms.tm_sec = 0;
Expand Down

0 comments on commit ddbb299

Please sign in to comment.