On 18 January 2016 at 18:17, D. Hugh Redelmeier <[email protected]> wrote:
> New commits:
> commit f86565435a7c00f8419ced6631d131d35d18011e
> Author: D. Hugh Redelmeier <[email protected]>
> Date: Mon Jan 18 18:16:33 2016 -0500
>
> pluto ikev2_spdb_struct.c: initialize structs the old way for old GCC
Actually this commit contained two changes.
Firstly, I like this:
+static bool print_join(struct print *buf, int n)
if (n < 0 || buf->pos + n > sizeof(buf->buf))
return FALSE;
buf->pos += n;
return TRUE;
}
but needs a further tweak (I was also going through it carefully today
as part of more logging). It should be:
if (n < 0)
return FALSE;
if (buf->pos + n >= sizeof(buf->buf)) {
buf->pos = sizeof(buf->buf);
return FALSE;
}
as, otherwise it will keep rewriting the end of the buffer. I'm
tempted to also also rewrite the tail of the buffer to "...".
However, for this:
- struct print buf = {0};
+ struct print buf;
+ print_init(&buf);
and:
- *proposal = (struct ikev2_proposal) {0};
+ static struct ikev2_proposal zero_proposal; /*
naturally zero */
as discussed here,
http://stackoverflow.com/questions/1538943/why-is-the-compiler-throwing-this-warning-missing-initializer-isnt-the-stru
the code's behaviour is very well defined (both for C90 and C99), it
is just that GCC throwing a needless hissy fit. Anyway, if we're
really going to pacify errors like this then the standard way is to
just add a coma like this:
struct print buf = {0,};
or this:
/* blat best with a new value */
*best = (struct ikev2_proposal) {
.propnum = remote_proposal.isap_protoid,
.protoid = remote_proposal.isap_protoid,
.remote_spi = remote_spi,
};
and this:
static struct ikev2_proposal default_ikev2_ike_proposal[] = {
{
.protoid = IKEv2_SEC_PROTO_IKE,
.transforms = {
[IKEv2_TRANS_TYPE_ENCR] = TR(ENCR_AES_GCM16_256), ...
(the latter two, didn't attract warnings :-)
_______________________________________________
Swan-dev mailing list
[email protected]
https://lists.libreswan.org/mailman/listinfo/swan-dev