[Openvpn-devel] keyingmaterialexporter.c: include strings.h

Message ID 20220203082620.8186-1-a@unstable.cc
State Accepted
Headers show
Series
  • [Openvpn-devel] keyingmaterialexporter.c: include strings.h
Related show

Commit Message

Antonio Quartulli Feb. 3, 2022, 8:26 a.m.
strcasecmp() was initially declared in string.h and subsequently moved
to strings.h. For historical reasons it still exists in string.h, but
would require _DEFAULT_SOURCE to be defined.

Due to the above, just include strings.h as currently dictated by the
manpage.

Fixes the following warning:

keying-material-exporter-demo/keyingmaterialexporter.c:155:14: warning: implicit declaration of function  strncasecmp’; did you mean ‘strncmp’? [-Wimplicit-function-declaration]
  155 |         if (!strncasecmp(objbuf, "CN", 2))
      |              ^~~~~~~~~~~
      |              strncmp

Signed-off-by: Antonio Quartulli <a@unstable.cc>
---
 .../keying-material-exporter-demo/keyingmaterialexporter.c       | 1 +
 1 file changed, 1 insertion(+)

Comments

Gert Doering Feb. 3, 2022, 8:32 a.m. | #1
Hi,

On Thu, Feb 03, 2022 at 09:26:20AM +0100, Antonio Quartulli wrote:
> strcasecmp() was initially declared in string.h and subsequently moved
> to strings.h. For historical reasons it still exists in string.h, but
> would require _DEFAULT_SOURCE to be defined.
> 
> Due to the above, just include strings.h as currently dictated by the
> manpage.

If we include strings.h, do we still need string.h then?

gert
Antonio Quartulli Feb. 3, 2022, 8:34 a.m. | #2
Hi,

On 03/02/2022 09:32, Gert Doering wrote:
> Hi,
> 
> On Thu, Feb 03, 2022 at 09:26:20AM +0100, Antonio Quartulli wrote:
>> strcasecmp() was initially declared in string.h and subsequently moved
>> to strings.h. For historical reasons it still exists in string.h, but
>> would require _DEFAULT_SOURCE to be defined.
>>
>> Due to the above, just include strings.h as currently dictated by the
>> manpage.
> 
> If we include strings.h, do we still need string.h then?

Yes, because the file also uses strlen() and strncmp() (declared in 
string.h)

Regards,
Gert Doering Feb. 3, 2022, 10:38 a.m. | #3
Acked-by: Gert Doering <gert@greenie.muc.de>

FreeBSD manpage confirms that <strings.h> should be used.  Insanity,
but well.

Your patch has been applied to the master and release/2.5 branch (bugfix,
even if not very critical).

commit d93a2b6160759d42d3fbaecc7fc868a7120221ef (master)
commit 2d31bf20dcffaab00a677bab06c8fe3816b6605b (release/2.5)
Author: Antonio Quartulli
Date:   Thu Feb 3 09:26:20 2022 +0100

     keyingmaterialexporter.c: include strings.h

     Signed-off-by: Antonio Quartulli <a@unstable.cc>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20220203082620.8186-1-a@unstable.cc>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23702.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c b/sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c
index 1f47cb35..e2820418 100644
--- a/sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c
+++ b/sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c
@@ -29,6 +29,7 @@ 
 
 #include <stdio.h>
 #include <string.h>
+#include <strings.h>
 #include <stdlib.h>
 
 #include "openvpn-plugin.h"