<p>David M. Lee has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7778">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Several fixes for compiling on macOS<br><br> * Remove macosx-version-min. It's unnecessary, and we do a really bad<br>   job of keeping it up to date (10.6 has been EOL for over three years)<br><br> * Ignore self-assign errors when using clang. This is a false positive<br>   with code like `x = ltohl(x)`<br><br> * Fix some signed char issues<br><br> * Fix compat macros for strlcat and strlcpy when the system defines<br>   them as macros<br><br> * Add clang pragmas to `AST_VECTOR_INSERT_AT()` to avoid tautology<br>   errors<br><br> * Fix format spec problems in `res_config_pgsql`. Apparently there's<br>   disagreement between compilers as to whether the math results in an<br>   unsigned char or an integer, so I assigned it to an int to remove the<br>   ambiguitry.<br><br> * Fix undeclared identifier bugs recently introduced in show sysinfo<br><br> * Fix "taking absolute value of unsigned type" warning in translate.c,<br>   because somebody decided it would be a good idea that the difference<br>   between two unsigned types ought to still be unsigned for some<br>   reason.<br><br>Change-Id: I3900881168c570c4177bf394caf33562e5c67f94<br>---<br>M Makefile<br>M Makefile.rules<br>M apps/app_adsiprog.c<br>M apps/app_sms.c<br>M include/asterisk/compat.h<br>M include/asterisk/vector.h<br>M main/Makefile<br>M main/asterisk.c<br>M main/translate.c<br>M res/res_config_pgsql.c<br>M res/res_http_websocket.c<br>11 files changed, 30 insertions(+), 26 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/78/7778/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/Makefile b/Makefile<br>index afd50c3..1130ec5 100644<br>--- a/Makefile<br>+++ b/Makefile<br>@@ -269,9 +269,8 @@<br> MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)<br> <br> ifneq ($(findstring darwin,$(OSARCH)),)<br>-  _ASTCFLAGS+=-D__Darwin__ -mmacosx-version-min=10.6<br>-  _SOLINK=-mmacosx-version-min=10.6 -Wl,-undefined,dynamic_lookup<br>-  _SOLINK+=/usr/lib/bundle1.o<br>+  _ASTCFLAGS+=-D__Darwin__<br>+  _SOLINK=-Wl,-undefined,dynamic_lookup<br>   SOLINK=-bundle $(_SOLINK)<br>   DYLINK=-Wl,-dylib $(_SOLINK)<br>   _ASTLDFLAGS+=-L/usr/local/lib<br>diff --git a/Makefile.rules b/Makefile.rules<br>index 2273644..813acbf 100644<br>--- a/Makefile.rules<br>+++ b/Makefile.rules<br>@@ -91,7 +91,7 @@<br> <br> # Clang -Werror warning suppressions<br> ifeq ($(C_COMPILER_FAMILY),clang)<br>-     CC_CFLAGS+=-Wno-unused-value -Wno-parentheses-equality<br>+       CC_CFLAGS+=-Wno-unused-value -Wno-parentheses-equality -Wno-self-assign<br> endif<br> <br> ifeq ($(GNU_LD),1)<br>diff --git a/apps/app_adsiprog.c b/apps/app_adsiprog.c<br>index 0659029..4307abf 100644<br>--- a/apps/app_adsiprog.c<br>+++ b/apps/app_adsiprog.c<br>@@ -1109,7 +1109,7 @@<br>                           tmp[7] = '\0';<br>                        }<br>                     /* Setup initial stuff */<br>-                    state->key->retstr[0] = 128;<br>+                   state->key->retstr[0] = (char) 128;<br>                     /* 1 has the length */<br>                        state->key->retstr[2] = state->key->id;<br>                   /* Put the Full name in */<br>@@ -1145,7 +1145,7 @@<br>                             break;<br>                        }<br>                     /* Setup sub */<br>-                      state->sub->data[0] = 130;<br>+                     state->sub->data[0] = (char) 130;<br>                       /* 1 is the length */<br>                         state->sub->data[2] = 0x0; /* Clear extensibility bit */<br>                        state->sub->datalen = 3;<br>@@ -1262,7 +1262,7 @@<br>                                 /* Something bad happened */<br>                          break;<br>                        }<br>-                    disp->data[0] = 129;<br>+                      disp->data[0] = (char) 129;<br>                        disp->data[1] = disp->datalen - 2;<br>                      disp->data[2] = ((lrci & 0x3) << 6) | disp->id;<br>                       disp->data[3] = wi;<br>diff --git a/apps/app_sms.c b/apps/app_sms.c<br>index 88985fb..f2a1a22 100644<br>--- a/apps/app_sms.c<br>+++ b/apps/app_sms.c<br>@@ -807,7 +807,7 @@<br>                                  *p++ = '\\';<br>                                  *p++ = 'r';<br>                           } else if (h->ud[n] < 32 || h->ud[n] == 127) {<br>-                                      *p++ = 191;<br>+                                  *p++ = (char) 191;<br>                            } else {<br>                                      *p++ = h->ud[n];<br>                           }<br>diff --git a/include/asterisk/compat.h b/include/asterisk/compat.h<br>index 2e89a39..024e8a8 100644<br>--- a/include/asterisk/compat.h<br>+++ b/include/asterisk/compat.h<br>@@ -124,7 +124,10 @@<br> void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff);<br> #endif<br> <br>+#undef      strlcat<br> #define       strlcat __use__ast_str__functions_not__strlcat__<br>+<br>+#undef    strlcpy<br> #define       strlcpy __use__ast_copy_string__not__strlcpy__<br> <br> #include <errno.h><br>diff --git a/include/asterisk/vector.h b/include/asterisk/vector.h<br>index 8bd1cef..6403630 100644<br>--- a/include/asterisk/vector.h<br>+++ b/include/asterisk/vector.h<br>@@ -306,6 +306,8 @@<br>  * of the vector itself.<br>  */<br> #define AST_VECTOR_INSERT_AT(vec, idx, elem) ({ \<br>+  _Pragma("clang diagnostic push"); \<br>+        _Pragma("clang diagnostic ignored \"-Wtautological-compare\""); \<br>         int res = 0; \<br>        size_t __move; \<br>      do { \<br>@@ -320,6 +322,7 @@<br>           (vec)->elems[(idx)] = (elem); \<br>            (vec)->current = ((idx) > (vec)->current ? (idx) : (vec)->current) + 1; \<br>         } while (0); \<br>+       _Pragma("clang diagnostic pop"); \<br>  res; \<br> })<br> <br>diff --git a/main/Makefile b/main/Makefile<br>index c724e20..cbcd3ab 100644<br>--- a/main/Makefile<br>+++ b/main/Makefile<br>@@ -63,8 +63,7 @@<br> <br> ifneq ($(findstring darwin,$(OSARCH)),)<br>   AST_LIBS+=-lresolv<br>-  ASTLINK=-mmacosx-version-min=10.6 -Wl,-undefined,dynamic_lookup -force_flat_namespace<br>-  ASTLINK+=/usr/lib/bundle1.o<br>+  ASTLINK=-Wl,-undefined,dynamic_lookup -force_flat_namespace<br> else<br> # These are used for all but Darwin<br>   ASTLINK+=-Wl,--export-dynamic<br>diff --git a/main/asterisk.c b/main/asterisk.c<br>index 450feb4..b3f86f1 100644<br>--- a/main/asterisk.c<br>+++ b/main/asterisk.c<br>@@ -714,12 +714,6 @@<br>        ast_free(swdev);<br>      return 1;<br> }<br>-#elif defined(HAVE_SYSCTL) && !defined(HAVE_SYSINFO)<br>-static int swapmode(int *used, int *total)<br>-{<br>-        *used = *total = 0;<br>-  return 1;<br>-}<br> #endif<br> <br> #if defined(HAVE_SYSINFO) || defined(HAVE_SYSCTL)<br>@@ -729,10 +723,10 @@<br>  uint64_t physmem, freeram;<br> #if defined(HAVE_SYSINFO) || defined(HAVE_SWAPCTL)<br>       uint64_t freeswap = 0;<br>+       int totalswap = 0;<br> #endif<br>   int nprocs = 0;<br>       long uptime = 0;<br>-     int totalswap = 0;<br> #if defined(HAVE_SYSINFO)<br>        struct sysinfo sys_info;<br> #elif defined(HAVE_SYSCTL)<br>@@ -740,7 +734,10 @@<br>   struct vmtotal vmtotal;<br>       struct timeval  boottime;<br>     time_t  now;<br>- int mib[2], pagesize, usedswap = 0;<br>+  int mib[2], pagesize;<br>+#if defined(HAVE_SWAPCTL)<br>+    int usedswap = 0;<br>+#endif<br>    size_t len;<br> #endif<br> <br>@@ -799,9 +796,11 @@<br>         len = sizeof(vmtotal);<br>        sysctl(mib, 2, &vmtotal, &len, NULL, 0);<br>      freeram = (vmtotal.t_free << pageshift);<br>+#if defined(HAVE_SWAPCTL)<br>    /* generate swap usage and totals */<br>  swapmode(&usedswap, &totalswap);<br>      freeswap = (totalswap - usedswap);<br>+#endif<br>   /* grab number of processes */<br> #if defined(__OpenBSD__)<br>     mib[0] = CTL_KERN;<br>diff --git a/main/translate.c b/main/translate.c<br>index 02717c5..3d3e0be 100644<br>--- a/main/translate.c<br>+++ b/main/translate.c<br>@@ -1415,10 +1415,10 @@<br>                          beststeps = matrix_get(x, y)->multistep;<br>                   } else if (matrix_get(x, y)->table_cost == besttablecost<br>                                   && matrix_get(x, y)->multistep == beststeps) {<br>-                            int gap_selected = abs(ast_format_get_sample_rate(best)<br>-                                      - ast_format_get_sample_rate(bestdst));<br>-                              int gap_current = abs(ast_format_get_sample_rate(src)<br>-                                        - ast_format_get_sample_rate(dst));<br>+                          int gap_selected = abs((int)(ast_format_get_sample_rate(best)<br>+                                        - ast_format_get_sample_rate(bestdst)));<br>+                             int gap_current = abs((int)(ast_format_get_sample_rate(src)<br>+                                  - ast_format_get_sample_rate(dst)));<br> <br>                               if (gap_current < gap_selected) {<br>                                  /* better than what we have so far */<br>diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c<br>index abd00ca..ca6cb83 100644<br>--- a/res/res_config_pgsql.c<br>+++ b/res/res_config_pgsql.c<br>@@ -1290,14 +1290,15 @@<br>                               struct ast_str *sql = ast_str_create(100);<br>                            char fieldtype[15];<br>                           PGresult *result;<br>+                            int length;<br> <br>                                if (requirements == RQ_CREATECHAR || type == RQ_CHAR) {<br>                                       /* Size is minimum length; make it at least 50% greater,<br>                                       * just to be sure, because PostgreSQL doesn't support<br>                                     * resizing columns. */<br>-                                      snprintf(fieldtype, sizeof(fieldtype), "CHAR(%hhu)",<br>-                                               size < 15 ? size * 2 :<br>-                                            (size * 3 / 2 > 255) ? 255 : size * 3 / 2);<br>+                                       length = size < 15 ? size * 2 :<br>+                                           (size * 3 / 2 > 255) ? 255 : size * 3 / 2;<br>+                                        snprintf(fieldtype, sizeof(fieldtype), "CHAR(%d)", length);<br>                                 } else if (type == RQ_INTEGER1 || type == RQ_UINTEGER1 || type == RQ_INTEGER2) {<br>                                      snprintf(fieldtype, sizeof(fieldtype), "INT2");<br>                             } else if (type == RQ_UINTEGER2 || type == RQ_INTEGER3 || type == RQ_UINTEGER3 || type == RQ_INTEGER4) {<br>diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c<br>index baaa40f..353b564 100644<br>--- a/res/res_http_websocket.c<br>+++ b/res/res_http_websocket.c<br>@@ -291,7 +291,7 @@<br> /*! \brief Close function for websocket session */<br> int AST_OPTIONAL_API_NAME(ast_websocket_close)(struct ast_websocket *session, uint16_t reason)<br> {<br>-     char frame[4] = { 0, }; /* The header is 2 bytes and the reason code takes up another 2 bytes */<br>+     unsigned char frame[4] = { 0, }; /* The header is 2 bytes and the reason code takes up another 2 bytes */<br>     int res;<br> <br>   if (session->close_sent) {<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7778">change 7778</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/7778"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I3900881168c570c4177bf394caf33562e5c67f94 </div>
<div style="display:none"> Gerrit-Change-Number: 7778 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: David M. Lee <dlee@digium.com> </div>