1
0
mirror of https://github.com/tmate-io/tmate-ssh-server.git synced 2020-11-18 19:53:51 -08:00

Cleanup warnings

This commit is contained in:
Nicolas Viennot 2019-11-07 09:02:58 -05:00
parent 975f60d2ac
commit 7f26d860b5
10 changed files with 29 additions and 10 deletions

View File

@ -37,8 +37,8 @@ CFLAGS += -g
CFLAGS += -Wno-long-long -Wall -W -Wnested-externs -Wformat=2
CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare
CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align
CFLAGS += -Wdeclaration-after-statement -Wno-pointer-sign -Wno-attributes
CFLAGS += -Wundef -Wbad-function-cast -Winline
CFLAGS += -Wno-pointer-sign -Wno-attributes
CPPFLAGS += -DDEBUG
endif
if IS_COVERAGE
@ -48,6 +48,9 @@ endif
CPPFLAGS += -iquote.
endif
CFLAGS += -Wno-unused-parameter -Wno-unused-variable -Wno-null-pointer-arithmetic
CFLAGS += -Wno-format-nonliteral
# Set flags for Solaris.
if IS_SUNOS
if IS_GCC

View File

@ -52,6 +52,8 @@
#include <stdlib.h>
#include <string.h>
#include "compat.h"
#define Assert(Cond) if (!(Cond)) abort()
static const char Base64[] =
@ -122,7 +124,7 @@ static const char Pad64 = '=';
*/
int
b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
b64_ntop(const char *src, size_t srclength, char *target, size_t targsize) {
size_t datalength = 0;
uint8_t input[3];
uint8_t output[4];

View File

@ -2,6 +2,7 @@
AC_INIT(tmate-ssh-server, 2.3.0)
AM_SILENT_RULES([yes])
AC_CONFIG_AUX_DIR(etc)
AM_INIT_AUTOMAKE([foreign subdir-objects])

13
log.c
View File

@ -81,6 +81,7 @@ void init_logging(const char *program_name, bool use_syslog, int log_level)
}
/* Write a log message. */
__attribute__((__format__(__printf__, 2, 0)))
static void
log_vwrite(int level, const char *msg, va_list ap)
{
@ -121,6 +122,7 @@ log_debug(const char *msg, ...)
}
/* Log a critical error with error string and die. */
__attribute__((__format__(__printf__, 1, 0)))
__dead void
fatal(const char *msg, ...)
{
@ -130,11 +132,13 @@ fatal(const char *msg, ...)
va_start(ap, msg);
if (asprintf(&fmt, "fatal: %s: %s", msg, strerror(errno)) == -1)
exit(1);
log_vwrite(LOG_CRIT, fmt, ap);
msg = fmt;
log_vwrite(LOG_CRIT, msg, ap);
exit(1);
}
/* Log a critical error and die. */
__attribute__((__format__(__printf__, 1, 0)))
__dead void
fatalx(const char *msg, ...)
{
@ -144,10 +148,12 @@ fatalx(const char *msg, ...)
va_start(ap, msg);
if (asprintf(&fmt, "fatal: %s", msg) == -1)
exit(1);
log_vwrite(LOG_CRIT, fmt, ap);
msg = fmt;
log_vwrite(LOG_CRIT, msg, ap);
exit(1);
}
__attribute__((__format__(__printf__, 2, 0)))
void tmate_log(int level, const char *msg, ...)
{
char *fmt;
@ -160,7 +166,8 @@ void tmate_log(int level, const char *msg, ...)
if (asprintf(&fmt, "(tmate) %s", msg) < 0)
exit(1);
log_vwrite(level, fmt, ap);
msg = fmt;
log_vwrite(level, msg, ap);
va_end(ap);
free(fmt);

View File

@ -28,7 +28,9 @@ char *osdep_get_name(int, char *);
char *osdep_get_cwd(int);
struct event_base *osdep_event_init(void);
#ifndef __unused
#define __unused __attribute__ ((__unused__))
#endif
char *
osdep_get_name(int fd, __unused char *tty)

2
proc.c
View File

@ -100,6 +100,7 @@ proc_event_cb(__unused int fd, short events, void *arg)
proc_update_event(peer);
}
#ifndef TMATE
static void
proc_signal_cb(int signo, __unused short events, void *arg)
{
@ -107,6 +108,7 @@ proc_signal_cb(int signo, __unused short events, void *arg)
tp->signalcb(signo);
}
#endif
static int
peer_check_version(struct tmuxpeer *peer, struct imsg *imsg)

View File

@ -564,6 +564,7 @@ session_group_index(struct session_group *sg)
}
fatalx("session group not found");
for(;;);
}
/*

View File

@ -1,5 +1,6 @@
#include "tmate.h"
#include <errno.h>
#include <signal.h>
struct tmate_session _tmate_session, *tmate_session = &_tmate_session;

View File

@ -339,10 +339,8 @@ static int get_client_ip_proxy_protocol(int fd, char *dst, size_t len)
tok_num = 0;
for (char *tok = strtok(header, " "); tok; tok = strtok(NULL, " "), tok_num++) {
if (tok_num == 1) {
strncpy(dst, tok, len);
dst[len-1] = '\0';
}
if (tok_num == 1)
strlcpy(dst, tok, len);
}
if (tok_num != 5)

View File

@ -94,6 +94,7 @@ xasprintf(char **ret, const char *fmt, ...)
return i;
}
__attribute__((__format__(__printf__, 2, 0)))
int
xvasprintf(char **ret, const char *fmt, va_list ap)
{
@ -120,6 +121,7 @@ xsnprintf(char *str, size_t len, const char *fmt, ...)
return i;
}
__attribute__((__format__(__printf__, 3, 0)))
int
xvsnprintf(char *str, size_t len, const char *fmt, va_list ap)
{