Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Some misc fixes #49

Merged
merged 1 commit into from
Mar 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CFG_DIR = $(BASE_DIR)/cfg
LIBS = toxcore ncursesw libconfig libcurl

CFLAGS ?= -g
CFLAGS += -std=gnu99 -pthread -Wall -fstack-protector-all
CFLAGS += -std=gnu99 -pthread -Wall -Wpedantic -fstack-protector-all
CFLAGS += '-DTOXICVER="$(VERSION)"' -DHAVE_WIDECHAR -D_XOPEN_SOURCE_EXTENDED -D_FILE_OFFSET_BITS=64
CFLAGS += '-DPACKAGE_DATADIR="$(abspath $(DATADIR))"'
CFLAGS += ${USER_CFLAGS}
Expand Down
2 changes: 1 addition & 1 deletion src/avatars.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int avatar_set(Tox *m, const char *path, size_t path_len)
return -1;
}

char PNG_signature[8] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A};
unsigned char PNG_signature[8] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A};

if (check_file_signature(PNG_signature, sizeof(PNG_signature), fp) != 0) {
fclose(fp);
Expand Down
11 changes: 8 additions & 3 deletions src/groupchat.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static void group_update_name_list(uint32_t groupnum)
{
GroupChat *chat = &groupchats[groupnum];

if (!chat) {
if (!chat->active) {
return;
}

Expand Down Expand Up @@ -359,7 +359,7 @@ static void update_peer_list(Tox *m, uint32_t groupnum, uint32_t num_peers)
{
GroupChat *chat = &groupchats[groupnum];

if (!chat) {
if (!chat->active) {
return;
}

Expand Down Expand Up @@ -403,6 +403,11 @@ static void groupchat_onGroupNameListChange(ToxWindow *self, Tox *m, uint32_t gr
}

GroupChat *chat = &groupchats[groupnum];

if (!chat->active) {
return;
}

Tox_Err_Conference_Peer_Query err;

uint32_t num_peers = tox_conference_peer_count(m, groupnum, &err);
Expand All @@ -427,7 +432,7 @@ static void groupchat_onGroupPeerNameChange(ToxWindow *self, Tox *m, uint32_t gr

GroupChat *chat = &groupchats[groupnum];

if (!chat) {
if (!chat->active) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/line_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ void line_info_print(ToxWindow *self)

if (type == OUT_MSG && timed_out(line->timestamp, NOREAD_FLAG_TIMEOUT)) {
wattron(win, COLOR_PAIR(RED));
wprintw(win, " x", line->msg);
wprintw(win, " x");
wattroff(win, COLOR_PAIR(RED));

if (line->noread_flag == false) {
Expand Down
7 changes: 5 additions & 2 deletions src/misc_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,10 @@ bool file_exists(const char *path)
File_Type file_type(const char *path)
{
struct stat s;
stat(path, &s);

if (stat(path, &s) == -1) {
return FILE_TYPE_OTHER;
}

switch (s.st_mode & S_IFMT) {
case S_IFDIR:
Expand Down Expand Up @@ -521,7 +524,7 @@ off_t file_size(const char *path)
Returns 0 if they are the same, 1 if they differ, and -1 on error.

On success this function will seek back to the beginning of fp */
int check_file_signature(const char *signature, size_t size, FILE *fp)
int check_file_signature(const unsigned char *signature, size_t size, FILE *fp)
{
char buf[size];

Expand Down
2 changes: 1 addition & 1 deletion src/misc_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ off_t file_size(const char *path);
Returns 0 if they are the same, 1 if they differ, and -1 on error.

On success this function will seek back to the beginning of fp */
int check_file_signature(const char *signature, size_t size, FILE *fp);
int check_file_signature(const unsigned char *signature, size_t size, FILE *fp);

/* sets window title in tab bar. */
void set_window_title(ToxWindow *self, const char *title, int len);
Expand Down
2 changes: 1 addition & 1 deletion src/name_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void *lookup_thread_func(void *data)
int proxy_ret = set_curl_proxy(c_handle, arg_opts.proxy_address, arg_opts.proxy_port, arg_opts.proxy_type);

if (proxy_ret != 0) {
lookup_error(self, "Failed to set proxy (error %d)\n");
lookup_error(self, "Failed to set proxy (error %d)\n", proxy_ret);
goto on_exit;
}

Expand Down