move array bounds gcc workaround outside function 18/2918/1
authorAndy Green <andy.green@linaro.org>
Wed, 16 Jan 2013 09:46:00 +0000 (17:46 +0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 7 Mar 2013 21:01:26 +0000 (13:01 -0800)
Signed-off-by: Andy Green <andy.green@linaro.org>
test-server/test-server.c

index 620c6f2..c7861cf 100644 (file)
@@ -126,6 +126,11 @@ static const struct serveable whitelist[] = {
        { "/test.html", "text/html" },
 };
 
+/* some versions of gcc see a false positive here, workaround */
+#ifdef __GNUC__
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
+
 /* this protocol server (always the first one) just knows how to do HTTP */
 
 static int callback_http(struct libwebsocket_context *context,
@@ -252,18 +257,12 @@ static int callback_http(struct libwebsocket_context *context,
                 * old end guy goes into vacant slot in hash table
                 */
 
-/* some versions of gcc see a false positive here, workaround */
-#ifdef __GNUC__
-#pragma GCC diagnostic ignored "-Warray-bounds"
-#endif
                pollfd_count[hash]--;
                if (pollfd_count[hash]) {
                        pollfd_maps[hash][n].index = pollfd_maps[hash][pollfd_count[hash]].index;
                        pollfd_maps[hash][n].fd = pollfd_maps[hash][pollfd_count[hash]].fd;
                }
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+
                break;
 
        case LWS_CALLBACK_SET_MODE_POLL_FD:
@@ -296,6 +295,9 @@ static int callback_http(struct libwebsocket_context *context,
        return 0;
 }
 
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
 
 /*
  * this is just an example of parsing handshake headers, you don't need this