Content-Type: multipart/alternative; boundary="------------MxvKkLFUJRj0PTE0dGIiilbb" Message-ID: Date: Mon, 27 Mar 2023 21:45:53 +0200 MIME-Version: 1.0 Content-Language: en-US References: <20230327114937.28246-1-selva.nair@...277...> <139d5059-25b8-e968-2996-5b3bc225ba3b@...68...> From: Matthias Andree In-Reply-To: Subject: Re: [Openvpn-devel] [PATCH] Make cert_data.h and test_cryptoapi/pkcs11.c MSVC compliant List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Selva Nair Cc: openvpn-devel@lists.sourceforge.net This is a multi-part message in MIME format. --------------MxvKkLFUJRj0PTE0dGIiilbb Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable Am 27.03.23 um 16:45 schrieb Selva Nair: > Hi, > > On Mon, Mar 27, 2023 at 9:59=E2=80=AFAM Matthias Andree > wrote: > > Am 27.03.23 um 13:49 schrieb selva.nair@...277...: > > From: Selva Nair > > > > - Do not use non-literal initializers for static objects > > - Replace empty initializer {} by {0} > > Should we go to a revision, I would suggest to not make something > compliant to a compiler because that is assigning it way too much > power > and control. A terms such as "ready to be compiled with MSVC" or so > would be in order, or making this code compliant with some wisely > chosen > version of the ISO 9899 standard, aka. standard C. > > > In this case "MSVC compliant" was arguably a poor choice of words as > what the change=C2=A0does is to avoid non-C99 constructs. However it made > sense to refer to MSVC in the context of what prompted this patch. > > That said, in a cross-platform code base one often has to make changes > to please compilers just to get things to build. I don't mind what we're doing here... just that I want to avoid the impression as though MSVC were setting the standards. There's always MinGW-GCC... That being said, here's a proposal: ----- Subject: Make cert_data.h and test_cryptoapi/pkcs11.c C99 compliant ...to fix compilation on MSVC 2143 : - Do not use non-literal initializers for static objects - Replace empty initializer {} by {0} > > Signed-off-by: Selva Nair > ----- > I was not getting rid of any defines -- just trying to avoid defines > if it can be done without jumping through too many hoops. Right, > (key1) would be better. > > Instead of making key2 local, we can write it out fully without > referring to the fact that key1 =3D key2. The latter was anyway a lazy > man's choice, not relevant for the working of the tests. > > If anyone feels strongly I can submit a v2 with key2, key4, and cname4 > fully written out like: That is not what I am proposing, redundance in source code is not a valid "fix" or approach... -> [1] It's just... I have been writing too much C++14 or C++17 code lately (on MSVC 2015, 2017, 2022 and with MS Build Tools 2019 because that was the customer's newest-limit) to want to mess with C limitations that serve their purpose on paper, but are getting in the way in practice. Of course then you have discussions about C++ linkage (the only reasonable solution is "avoid"), exceptions (serious discussion what and where) and about contributors. I am aware C++ is abhorred by some but I usually find they set their minds in the first decade of the millennium, literally before C++11, but that would also be the side door to sneak it in because people who believe their strange OS doesn't have a C++ compiler can still compile OpenVPN proper, just not unit tests. > That may also make maintaining this data easier -- ie., any cert/key > pair could be replaced without affecting others. [1] So I would go the pragmatic way here and just change once there is really a need to replace certificates. It's only a test after all. --------------MxvKkLFUJRj0PTE0dGIiilbb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Am 27.03.23 um 16:45 schrieb Selva Nair:
Hi,

On Mon, Mar 27, 2023 at 9:59=E2=80=AFAM Matthias Andree <matt= hias.andree@...68...> wrote:
Am 27.03.23 um 13:49 schrieb selva.nair@...277...:
> From: Selva Nair <selv= a.nair@...277...>
>
> - Do not use non-literal initializers for static objects
> - Replace empty initializer {} by {0}

Should we go to a revision, I would suggest to not make something
compliant to a compiler because that is assigning it way too much power
and control. A terms such as "ready to be compiled with MSVC" or so
would be in order, or making this code compliant with some wisely chosen
version of the ISO 9899 standard, aka. standard C.

In this case "MSVC compliant" was arguably a poor choice of words as what the change=C2=A0does is to avoid non-C99 constructs. However it made sense to refer to MSVC in the context of what prompted this patch.

That said, in a cross-platform code base one often has to make changes to please compilers just to get things to build.

I don't mind what we're doing here... just that I want to avoid the impression as though MSVC were setting the standards. There's always MinGW-GCC...

That being said, here's a proposal:

-----

Subject: Make cert_data.h and test_cryptoapi/pkcs11.c C99 compliant

...to fix compilation on MSVC 2143 <insert actual version and relevant C language settings here>:

- Do not use non-literal initializers for static objects
- Replace empty initializer {} by {0}

> Signed-off-by: Selva Nair <selv= a.nair@...277...>

-----


I was not getting rid of any defines -- just trying to avoid defines if it can be done without jumping through too many hoops. Right, (key1) would be better.

Instead of making key2 local, we can write it out fully without referring to the fact that key1 =3D key2. The latter was anyway a lazy man's choice, not relevant for the working of the tests.

If anyone feels strongly I can submit a v2 with key2, key4, and cname4 fully written out like:

That is not what I am proposing, redundance in source code is not a valid "fix" or approach... -> [1]

It's just... I have been writing too much C++14 or C++17 code lately (on MSVC 2015, 2017, 2022 and with MS Build Tools 2019 because that was the customer's newest-limit) to want to mess with C limitations that serve their purpose on paper, but are getting in the way in practice. Of course then you have discussions about C++ linkage (the only reasonable solution is "avoid"), exceptions (serious discussion what and where) and about contributors. I am aware C++ is abhorred by some but I usually find they set their minds in the first decade of the millennium, literally before C++11, but that would also be the side door to sneak it in because people who believe their strange OS doesn't have a C++ compiler can still compile OpenVPN proper, just not unit tests.


That may also make maintaining this data easier -- ie., any cert/key pair could be replaced without affecting others.
[1] So I would go the pragmatic way here and just change once there is really a need to replace certificates. It's only a test after all.
--------------MxvKkLFUJRj0PTE0dGIiilbb--