Created
December 29, 2017 04:14
-
-
Save leedm777/9e72cd18d056c54f6a6ae67ee2766957 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 9b78a4bf59d87412ae29a1af918f345182502309 | |
Author: David M. Lee <[email protected]> | |
Date: Wed Dec 27 23:47:14 2017 -0600 | |
Various fixes for macOS | |
* Removed bundle1.o and macosx-version-min. This is unnecessary, and | |
become dated more quickly than we update macOS support (10.6 has been | |
EOL for over three years) | |
* Add some explicit casting to fix clang errors/warnings | |
* Fix when strlcat and strlcpy are macros | |
* Ignore self-assign errors, because macros | |
* Ignore tautological errors in AST_VECTOR_INSERT_AT(), because macros | |
* Fix warnings for taking the difference of unsigned values | |
* Fix #ifdef logic around sysinfo and swapctl | |
* Fix some sign and type nits that clang complains about | |
Change-Id: I2ca95cd6ae2ce4b7034f8a8afdcac42bfc3d05a6 | |
diff --git a/Makefile b/Makefile | |
index afd50c3cc9..1130ec530e 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -269,9 +269,8 @@ SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall) | |
MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree) | |
ifneq ($(findstring darwin,$(OSARCH)),) | |
- _ASTCFLAGS+=-D__Darwin__ -mmacosx-version-min=10.6 | |
- _SOLINK=-mmacosx-version-min=10.6 -Wl,-undefined,dynamic_lookup | |
- _SOLINK+=/usr/lib/bundle1.o | |
+ _ASTCFLAGS+=-D__Darwin__ | |
+ _SOLINK=-Wl,-undefined,dynamic_lookup | |
SOLINK=-bundle $(_SOLINK) | |
DYLINK=-Wl,-dylib $(_SOLINK) | |
_ASTLDFLAGS+=-L/usr/local/lib | |
diff --git a/Makefile.rules b/Makefile.rules | |
index 2273644100..813acbf5cc 100644 | |
--- a/Makefile.rules | |
+++ b/Makefile.rules | |
@@ -91,7 +91,7 @@ CXX_CFLAGS=$(PTHREAD_CFLAGS) $(filter-out -Wstrict-prototypes -Wmissing-prototyp | |
# Clang -Werror warning suppressions | |
ifeq ($(C_COMPILER_FAMILY),clang) | |
- CC_CFLAGS+=-Wno-unused-value -Wno-parentheses-equality | |
+ CC_CFLAGS+=-Wno-unused-value -Wno-parentheses-equality -Wno-self-assign | |
endif | |
ifeq ($(GNU_LD),1) | |
diff --git a/apps/app_adsiprog.c b/apps/app_adsiprog.c | |
index 0659029956..4307abf8e9 100644 | |
--- a/apps/app_adsiprog.c | |
+++ b/apps/app_adsiprog.c | |
@@ -1109,7 +1109,7 @@ static int adsi_process(struct adsi_script *state, char *buf, const char *script | |
tmp[7] = '\0'; | |
} | |
/* Setup initial stuff */ | |
- state->key->retstr[0] = 128; | |
+ state->key->retstr[0] = (char) 128; | |
/* 1 has the length */ | |
state->key->retstr[2] = state->key->id; | |
/* Put the Full name in */ | |
@@ -1145,7 +1145,7 @@ static int adsi_process(struct adsi_script *state, char *buf, const char *script | |
break; | |
} | |
/* Setup sub */ | |
- state->sub->data[0] = 130; | |
+ state->sub->data[0] = (char) 130; | |
/* 1 is the length */ | |
state->sub->data[2] = 0x0; /* Clear extensibility bit */ | |
state->sub->datalen = 3; | |
@@ -1262,7 +1262,7 @@ static int adsi_process(struct adsi_script *state, char *buf, const char *script | |
/* Something bad happened */ | |
break; | |
} | |
- disp->data[0] = 129; | |
+ disp->data[0] = (char) 129; | |
disp->data[1] = disp->datalen - 2; | |
disp->data[2] = ((lrci & 0x3) << 6) | disp->id; | |
disp->data[3] = wi; | |
diff --git a/apps/app_sms.c b/apps/app_sms.c | |
index 88985fbc50..f2a1a22728 100644 | |
--- a/apps/app_sms.c | |
+++ b/apps/app_sms.c | |
@@ -807,7 +807,7 @@ static void sms_log(sms_t * h, char status) | |
*p++ = '\\'; | |
*p++ = 'r'; | |
} else if (h->ud[n] < 32 || h->ud[n] == 127) { | |
- *p++ = 191; | |
+ *p++ = (char) 191; | |
} else { | |
*p++ = h->ud[n]; | |
} | |
diff --git a/include/asterisk/compat.h b/include/asterisk/compat.h | |
index 2e89a39ebf..024e8a8693 100644 | |
--- a/include/asterisk/compat.h | |
+++ b/include/asterisk/compat.h | |
@@ -124,7 +124,10 @@ int __attribute__((format(printf, 2, 0))) vasprintf(char **strp, const char *fmt | |
void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff); | |
#endif | |
+#undef strlcat | |
#define strlcat __use__ast_str__functions_not__strlcat__ | |
+ | |
+#undef strlcpy | |
#define strlcpy __use__ast_copy_string__not__strlcpy__ | |
#include <errno.h> | |
diff --git a/include/asterisk/vector.h b/include/asterisk/vector.h | |
index 8bd1cefef7..6403630333 100644 | |
--- a/include/asterisk/vector.h | |
+++ b/include/asterisk/vector.h | |
@@ -306,6 +306,8 @@ AST_VECTOR(ast_vector_string, char *); | |
* of the vector itself. | |
*/ | |
#define AST_VECTOR_INSERT_AT(vec, idx, elem) ({ \ | |
+ _Pragma("clang diagnostic push"); \ | |
+ _Pragma("clang diagnostic ignored \"-Wtautological-compare\""); \ | |
int res = 0; \ | |
size_t __move; \ | |
do { \ | |
@@ -320,6 +322,7 @@ AST_VECTOR(ast_vector_string, char *); | |
(vec)->elems[(idx)] = (elem); \ | |
(vec)->current = ((idx) > (vec)->current ? (idx) : (vec)->current) + 1; \ | |
} while (0); \ | |
+ _Pragma("clang diagnostic pop"); \ | |
res; \ | |
}) | |
diff --git a/main/Makefile b/main/Makefile | |
index c724e2012b..cbcd3ab535 100644 | |
--- a/main/Makefile | |
+++ b/main/Makefile | |
@@ -63,8 +63,7 @@ endif | |
ifneq ($(findstring darwin,$(OSARCH)),) | |
AST_LIBS+=-lresolv | |
- ASTLINK=-mmacosx-version-min=10.6 -Wl,-undefined,dynamic_lookup -force_flat_namespace | |
- ASTLINK+=/usr/lib/bundle1.o | |
+ ASTLINK=-Wl,-undefined,dynamic_lookup -force_flat_namespace | |
else | |
# These are used for all but Darwin | |
ASTLINK+=-Wl,--export-dynamic | |
diff --git a/main/asterisk.c b/main/asterisk.c | |
index 450feb47ce..b3f86f10f3 100644 | |
--- a/main/asterisk.c | |
+++ b/main/asterisk.c | |
@@ -714,12 +714,6 @@ static int swapmode(int *used, int *total) | |
ast_free(swdev); | |
return 1; | |
} | |
-#elif defined(HAVE_SYSCTL) && !defined(HAVE_SYSINFO) | |
-static int swapmode(int *used, int *total) | |
-{ | |
- *used = *total = 0; | |
- return 1; | |
-} | |
#endif | |
#if defined(HAVE_SYSINFO) || defined(HAVE_SYSCTL) | |
@@ -729,10 +723,10 @@ static char *handle_show_sysinfo(struct ast_cli_entry *e, int cmd, struct ast_cl | |
uint64_t physmem, freeram; | |
#if defined(HAVE_SYSINFO) || defined(HAVE_SWAPCTL) | |
uint64_t freeswap = 0; | |
+ int totalswap = 0; | |
#endif | |
int nprocs = 0; | |
long uptime = 0; | |
- int totalswap = 0; | |
#if defined(HAVE_SYSINFO) | |
struct sysinfo sys_info; | |
#elif defined(HAVE_SYSCTL) | |
@@ -740,7 +734,10 @@ static char *handle_show_sysinfo(struct ast_cli_entry *e, int cmd, struct ast_cl | |
struct vmtotal vmtotal; | |
struct timeval boottime; | |
time_t now; | |
- int mib[2], pagesize, usedswap = 0; | |
+ int mib[2], pagesize; | |
+#if defined(HAVE_SWAPCTL) | |
+ int usedswap = 0; | |
+#endif | |
size_t len; | |
#endif | |
@@ -799,9 +796,11 @@ static char *handle_show_sysinfo(struct ast_cli_entry *e, int cmd, struct ast_cl | |
len = sizeof(vmtotal); | |
sysctl(mib, 2, &vmtotal, &len, NULL, 0); | |
freeram = (vmtotal.t_free << pageshift); | |
+#if defined(HAVE_SWAPCTL) | |
/* generate swap usage and totals */ | |
swapmode(&usedswap, &totalswap); | |
freeswap = (totalswap - usedswap); | |
+#endif | |
/* grab number of processes */ | |
#if defined(__OpenBSD__) | |
mib[0] = CTL_KERN; | |
diff --git a/main/translate.c b/main/translate.c | |
index 02717c5ed1..876da45326 100644 | |
--- a/main/translate.c | |
+++ b/main/translate.c | |
@@ -1415,10 +1415,12 @@ int ast_translator_best_choice(struct ast_format_cap *dst_cap, | |
beststeps = matrix_get(x, y)->multistep; | |
} else if (matrix_get(x, y)->table_cost == besttablecost | |
&& matrix_get(x, y)->multistep == beststeps) { | |
- int gap_selected = abs(ast_format_get_sample_rate(best) | |
- - ast_format_get_sample_rate(bestdst)); | |
- int gap_current = abs(ast_format_get_sample_rate(src) | |
- - ast_format_get_sample_rate(dst)); | |
+ int gap_selected = | |
+ ast_format_get_sample_rate(best) - ast_format_get_sample_rate(bestdst); | |
+ gap_selected = abs(gap_selected); | |
+ int gap_current = | |
+ ast_format_get_sample_rate(src) - ast_format_get_sample_rate(dst); | |
+ gap_current = abs(gap_current); | |
if (gap_current < gap_selected) { | |
/* better than what we have so far */ | |
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c | |
index abd00ca3a8..2310f39def 100644 | |
--- a/res/res_config_pgsql.c | |
+++ b/res/res_config_pgsql.c | |
@@ -1295,7 +1295,7 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap | |
/* Size is minimum length; make it at least 50% greater, | |
* just to be sure, because PostgreSQL doesn't support | |
* resizing columns. */ | |
- snprintf(fieldtype, sizeof(fieldtype), "CHAR(%hhu)", | |
+ snprintf(fieldtype, sizeof(fieldtype), "CHAR(%d)", | |
size < 15 ? size * 2 : | |
(size * 3 / 2 > 255) ? 255 : size * 3 / 2); | |
} else if (type == RQ_INTEGER1 || type == RQ_UINTEGER1 || type == RQ_INTEGER2) { | |
diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c | |
index baaa40fd90..353b564df8 100644 | |
--- a/res/res_http_websocket.c | |
+++ b/res/res_http_websocket.c | |
@@ -291,7 +291,7 @@ int AST_OPTIONAL_API_NAME(ast_websocket_server_remove_protocol)(struct ast_webso | |
/*! \brief Close function for websocket session */ | |
int AST_OPTIONAL_API_NAME(ast_websocket_close)(struct ast_websocket *session, uint16_t reason) | |
{ | |
- char frame[4] = { 0, }; /* The header is 2 bytes and the reason code takes up another 2 bytes */ | |
+ unsigned char frame[4] = { 0, }; /* The header is 2 bytes and the reason code takes up another 2 bytes */ | |
int res; | |
if (session->close_sent) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment