[Git][NTPsec/ntpsec][master] Wrap CLang pragmas under __clang__ to avoid non-clang compiler warnings.

Amar Takhar gitlab at mg.gitlab.com
Fri Dec 4 21:50:49 UTC 2015


Amar Takhar pushed to branch master at NTPsec / ntpsec


Commits:
da0cfa0f by Amar Takhar at 2015-12-04T16:50:06Z
Wrap CLang pragmas under __clang__ to avoid non-clang compiler warnings.

- - - - -


2 changed files:

- tests/libntp/msyslog.c
- tests/ntpdig/packetProcessing.c


Changes:

=====================================
tests/libntp/msyslog.c
=====================================
--- a/tests/libntp/msyslog.c
+++ b/tests/libntp/msyslog.c
@@ -90,11 +90,15 @@ TEST(msyslog, msnprintfHangingPercent)
 	ZERO(exp_buf);
 	ZERO(act_buf);
 /* warning: format string contains '\0' within the string body [-Wformat] */
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat"
+#ifdef __clang__
+#  pragma clang diagnostic push
+#  pragma clang diagnostic ignored "-Wformat"
+#endif
 	exp_cnt = snprintf(exp_buf, sizeof(exp_buf), "percent then nul term then non-nul %\0oops!");
 	act_cnt = msnprintf(act_buf, sizeof(act_buf), "percent then nul term then non-nul %\0oops!");
-#pragma clang diagnostic pop
+#ifdef __clang__
+#  pragma clang diagnostic pop
+#endif
 
 	TEST_ASSERT_EQUAL(exp_cnt, act_cnt);
 	TEST_ASSERT_EQUAL_STRING(exp_buf, act_buf);


=====================================
tests/ntpdig/packetProcessing.c
=====================================
--- a/tests/ntpdig/packetProcessing.c
+++ b/tests/ntpdig/packetProcessing.c
@@ -101,10 +101,14 @@ TEST(packetProcessing, TooShortExtensionFieldLength) {
 	 * This lengths must be multiples of 4 bytes, which gives
 	 * a minimum of 4 byte extension field length. */
 /* warning: array index 7 is past the end of the array (which contains 6 elements) [-Warray-bounds] */
+#ifdef __clang__
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Warray-bounds"
+#endif
 	testpkt.exten[7] = htonl(3); // 3 bytes is too short.
+#ifdef __clang__
 #pragma clang diagnostic pop
+#endif
 
 	/* We send in a pkt_len of header size + 4 byte extension
 	 * header + 24 byte MAC, this prevents the length error to



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/da0cfa0f701f61cfc0890f61f2ec1cb82791d084
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151204/b3820e06/attachment.html>


More information about the vc mailing list