Skip to content

Commit

Permalink
Suppress warnings reported by CodeQL
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Dec 18, 2024
1 parent 4032b59 commit cea7fa6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/libscrobbler2.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ scrobbler_status_t scrobbler_authentication(scrobbler_session_t *sbs,
token_hex[32] = '\0';

/* perform user authorization (callback function) */
sprintf(get_url, "%s?api_key=%s&token=%s",
snprintf(get_url, sizeof(get_url), "%s?api_key=%s&token=%s",
sbs->auth_url, api_key_hex, token_hex);
if (callback(get_url) != 0) {
sb_curl_cleanup(curl, &response);
Expand Down
32 changes: 12 additions & 20 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,25 +180,6 @@ static void cmusfm_initialization(void) {
printf("Error: unable to write file: %s\n", cmusfm_config_file);
}

/* Spawn server process of cmusfm by simply forking ourself and exec with
* special "server" argument. */
static void cmusfm_spawn_server_process(const char *cmusfm) {

pid_t pid;

if ((pid = fork()) == -1) {
perror("ERROR: Fork server");
exit(EXIT_FAILURE);
}

if (pid == 0) {
execlp(cmusfm, cmusfm, "server", NULL);
perror("ERROR: Exec server");
exit(EXIT_FAILURE);
}

}

int main(int argc, char *argv[]) {

struct cmtrack_info *tinfo;
Expand Down Expand Up @@ -237,8 +218,19 @@ int main(int argc, char *argv[]) {
}

if (cmusfm_server_check() == 0) {
cmusfm_spawn_server_process(argv[0]);

pid_t pid;
if ((pid = fork()) == -1) {
perror("ERROR: Fork server");
return EXIT_FAILURE;
}

if (pid == 0)
return cmusfm_server_start();

/* wait for the server to start */
sleep(1);

}

if (cmusfm_server_send_track(tinfo) != 0) {
Expand Down
6 changes: 4 additions & 2 deletions src/notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include <stdlib.h>
#include <string.h>

#include <glib.h>
#include <libnotify/notify.h>

#include "debug.h"
Expand Down Expand Up @@ -68,6 +70,8 @@ void cmusfm_notify_show(const scrobbler_trackinfo_t *sb_tinf, const char *icon)
else
cmus_notify = notify_notification_new(track, body, icon);

free(body);

if (!notify_notification_show(cmus_notify, &error)) {
debug("Desktop notify error: %s", error->message);
g_error_free(error);
Expand All @@ -77,8 +81,6 @@ void cmusfm_notify_show(const scrobbler_trackinfo_t *sb_tinf, const char *icon)
cmusfm_notify_free();
}

if (body != NULL)
free(body);
}

/* Initialize notification system. */
Expand Down

0 comments on commit cea7fa6

Please sign in to comment.