Attention is currently required from: arehbein.
neels has posted comments on this change. (
https://gerrit.osmocom.org/c/osmo-upf/+/30461
)
Change subject: tunmap: choose local GTP addr by Network Instance IEs
......................................................................
Patch Set 2:
(2 comments)
File src/osmo-upf/up_session.c:
https://gerrit.osmocom.org/c/osmo-upf/+/30461/comment/1fae73dc_3bb0db2c
PS2, Line 124: struct osmo_sockaddr osa = {};
This (`{}`) doesn't seem to be ISO C (or I
misunderstood the syntax section of the latest draft), is […]
yeah we've had
some discussions on that before.
struct foo f = {};
initializes all members to zero.
It was then brought to my attention that the "normal" way to do this is:
struct foo = {0};
I find this syntax odd, because 0 is assigned to the first member of a struct, and the
rest of the members get an implicit zero because they are not present. that works fine
with a struct like this:
struct foo {
int first;
int second;
};
but when the struct has "nested" members the {0} syntax looks incorrrect:
struct foo {
int arr[23];
};
struct foo f = {0};
the correct way to initialize the arr member would be
struct foo f = { {0, 1, 2} };
or
struct foo f = { {0} };
Now, in many cases, just f = {0} magically works. I'm not sure whether that is
special-cased by the compiler or what. So then I started to adopt the "{0}"
syntax. But *then*, a while passed and i did encounter a case where i could not initialize
a struct with "{0}". i don't remember in detail, but it was a nested struct,
maybe like
struct foo {
struct {
struct baz memb;
} bar;
};
So I hit a case where "{0}" doesn't compile, but "{}" works
without problems.
Long story short, i have now gone back to using and prefering "{}", because it
simply makes more sense to me, and all compilers we encounter in osmocom seem to be fine
with that.
BTW I also often use a syntax like
f = (struct foo){};
which is a memset(0). or
f = (struct foo){
.bar = {
.baz = { 1, "alpha" },
},
};
to zero-initialize the struct and place select values at the same time, avoiding a lot of
repetition.
I've gotten some frowns from code review, but so far this syntax has always worked as
expected.
File tests/netinst.vty:
https://gerrit.osmocom.org/c/osmo-upf/+/30461/comment/236b7fe7_326ad830
PS2, Line 32: <cr>
Trailing space (if that's how it looks in Gerrit).
Not sure if we care if it isn't source code...
this trailing whitespace is
returned from the telnet VTY, if we fix that the test will fail. so need to keep that.
--
To view, visit
https://gerrit.osmocom.org/c/osmo-upf/+/30461
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-upf
Gerrit-Branch: master
Gerrit-Change-Id: I15ee046a1c37b83b8a83527a67a6215a30106d81
Gerrit-Change-Number: 30461
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: arehbein <arehbein(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: arehbein <arehbein(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 09 Dec 2022 17:11:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: arehbein <arehbein(a)sysmocom.de>
Gerrit-MessageType: comment