Compound Literal - xlc and gcc differences can be patched

Michael Felt michael at felt.demon.nl
Tue Oct 11 20:25:37 UTC 2016


Since I so miserably misspelled packaging - a new thread specific to the 
issue at hand.

I found a "workaround". In short, xlc does not accept arrays of nested 
array - the bottom line (best message) is: 1506-995 (S) An aggregate 
containing a flexible array member cannot be used as a member of a 
structure or as an array element.

At the core - all the other messages come because this (I shall call it 
nesting).

For the test-http-auth.c file I have a patch (attached).

make ran for while with no issue, then it started running into several 
files with this same style of specification - doveadm-dict.c being the 
first one. I ran "make -i" and I notice several files with this - for 
xlc - "unaccepted" syntax.

Please look at the patch - what it basically is - and let me know 
whether you would consider accepting patches in this form (e.g., verify 
gcc (I assume) will accept it as well). If your answer is yes, I shall 
proceed with the additional files (learn how your MACROS work!) and send 
them to you. Again, initially I would just send one, e.g., 
doveadm-dict.c - to be sure your regular compiler also builds this 
alternate specification.

Thank you for your consideration!

Michael

-------------- next part --------------
--- test-http-auth.c.orig	2016-06-29 20:01:30 +0000
+++ test-http-auth.c.new	2016-10-11 15:54:50 +0000
@@ -9,7 +9,7 @@
 struct http_auth_challenge_test {
 	const char *scheme;
 	const char *data;
-	struct http_auth_param *params;
+	struct http_auth_param params[];
 };
 
 struct http_auth_challenges_test {
@@ -17,65 +17,69 @@
 
 	struct http_auth_challenge_test *challenges;
 };
-
+/* The schemes */
+static const struct http_auth_challenge_test basic[] = {
+	{ .scheme = "Basic",
+	  .data = NULL,
+	  .params = {
+		(struct http_auth_param) { "realm", "WallyWorld" },
+		(struct http_auth_param) { }
+		}
+	},{
+	  .scheme = NULL
+	}
+};
+static const struct http_auth_challenge_test digest[] = {
+	{ .scheme = "Digest",
+	  .data = NULL,
+	  .params = (struct http_auth_param []) { 
+		{ "realm", "testrealm at host.com" },
+		{ "qop", "auth,auth-int" },
+		{ "nonce", "dcd98b7102dd2f0e8b11d0f600bfb0c093" },
+		{ "opaque", "5ccc069c403ebaf9f0171e9517f40e41" },
+		{ }
+	  }
+	},{
+	  .scheme = NULL
+	}
+};
+static const struct http_auth_challenge_test realms[] = {
+	{ .scheme = "Newauth",
+	  .data = NULL,
+	  .params = (struct http_auth_param []) { 
+		{ "realm", "apps" },
+		{ "type", "1" },
+		{ "title", "Login to \"apps\"" },
+		{ }
+	  }
+	},{
+	  .scheme = "Basic",
+	  .data = NULL,
+	  .params = (struct http_auth_param []) { 
+		{ "realm", "simple" },
+		{ }
+	 }
+	},{
+	  .scheme = NULL
+	}
+};
 /* Valid auth challenges tests */
 static const struct http_auth_challenges_test
 valid_auth_challenges_tests[] = {
 	{ 
 		.challenges_in = "Basic realm=\"WallyWorld\"",
-		.challenges = (struct http_auth_challenge_test []) {
-			{ .scheme = "Basic",
-				.data = NULL,
-				.params = (struct http_auth_param []) { 
-					{ "realm", "WallyWorld" }, { NULL, NULL }
-				}
-			},{
-				.scheme = NULL
-			}
-		}
+		.challenges = &basic
 	},{
 		.challenges_in = "Digest "
                  "realm=\"testrealm at host.com\", "
                  "qop=\"auth,auth-int\", "
                  "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", "
                  "opaque=\"5ccc069c403ebaf9f0171e9517f40e41\"",
-		.challenges = (struct http_auth_challenge_test []) {
-			{ .scheme = "Digest",
-				.data = NULL,
-				.params = (struct http_auth_param []) { 
-					{ "realm", "testrealm at host.com" },
-					{ "qop", "auth,auth-int" },
-					{ "nonce", "dcd98b7102dd2f0e8b11d0f600bfb0c093" },
-					{ "opaque", "5ccc069c403ebaf9f0171e9517f40e41" },
-					{ NULL, NULL }
-				}
-			},{
-				.scheme = NULL
-			}
-		}
+		.challenges = &digest
 	},{
 		.challenges_in = "Newauth realm=\"apps\", type=1, "
                      "title=\"Login to \\\"apps\\\"\", Basic realm=\"simple\"",
-		.challenges = (struct http_auth_challenge_test []) {
-			{ .scheme = "Newauth",
-				.data = NULL,
-				.params = (struct http_auth_param []) { 
-					{ "realm", "apps" },
-					{ "type", "1" },
-					{ "title", "Login to \"apps\"" },
-					{ NULL, NULL }
-				}
-			},{
-				.scheme = "Basic",
-				.data = NULL,
-				.params = (struct http_auth_param []) { 
-					{ "realm", "simple" },
-					{ NULL, NULL }
-				}
-			},{
-				.scheme = NULL
-			}
-		}
+		.challenges = &realms
 	}
 };
 
@@ -160,27 +164,18 @@
 
 	const char *scheme;
 	const char *data;
-	struct http_auth_param *params;
+	struct http_auth_param params[];
 };
-
-/* Valid auth credentials tests */
 static const struct http_auth_credentials_test
-valid_auth_credentials_tests[] = {
-	{ 
-		.credentials_in = "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
+basic_cred[] = {
+	{
 		.scheme = "Basic",
 		.data = "QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
 		.params = NULL
-	},{
-		.credentials_in = "Digest username=\"Mufasa\", "
-                 "realm=\"testrealm at host.com\", "
-                 "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", "
-                 "uri=\"/dir/index.html\", "
-                 "qop=auth, "
-                 "nc=00000001, "
-                 "cnonce=\"0a4f113b\", "
-                 "response=\"6629fae49393a05397450978507c4ef1\", "
-                 "opaque=\"5ccc069c403ebaf9f0171e9517f40e41\"",
+	}
+};
+static const struct http_auth_credentials_test mufasa[] = {
+	{
 		.scheme = "Digest",
 		.data = NULL,
 		.params = (struct http_auth_param []) {
@@ -198,6 +193,26 @@
 	}
 };
 
+/* Valid auth credentials tests */
+static const struct http_auth_credentials_test
+valid_auth_credentials_tests[] = {
+	{ 
+		.credentials_in = "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
+		.params = &basic_cred
+	},{
+		.credentials_in = "Digest username=\"Mufasa\", "
+                 "realm=\"testrealm at host.com\", "
+                 "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", "
+                 "uri=\"/dir/index.html\", "
+                 "qop=auth, "
+                 "nc=00000001, "
+                 "cnonce=\"0a4f113b\", "
+                 "response=\"6629fae49393a05397450978507c4ef1\", "
+                 "opaque=\"5ccc069c403ebaf9f0171e9517f40e41\"",
+                .params = &mufasa
+		}
+	};
+
 static const unsigned int valid_auth_credentials_test_count =
 	N_ELEMENTS(valid_auth_credentials_tests);
 


More information about the dovecot mailing list