Hi,

the output of GCC is pretty self explaining here:

interface.c: In function 'interface_create':
interface.c:25:9: warning: implicit declaration of function 'strncpy' 
[-Wimplicit-function-declaration]
   25 |         strncpy(iface->name, name, MAX_IFNAME_SIZE);
      |         ^~~~~~~
interface.c:9:1: note: include '<string.h>' or provide a declaration of 
'strncpy'
    8 | #include "interface.h"
  +++ |+#include <string.h>
    9 | 

That can be quite an issue with strncpy returning `char *` (sized 8 bytes on
machines most commonly today), but the implicit function returns `int` (sized 4
bytes on machines most commonly used today).

Btw: When compiled with a modern compiler and more diagnostics enabled, quite a
few warnings pop, many seem reasonable. Some examples (from clang 12, but GCC
11.2 has pretty good diagnostics, too):

./sk.h:76:11: note: did you mean 'sk_info'?
 * @param info      Struct containing obtained timestamping information.
          ^~~~
          sk_info

(and many more instances of mismatches in API documentation and API)

or

./sk.h:38:4: warning: unknown command tag name [-Wdocumentation-unknown-command]
 * @valid:            set to non-zero when the info struct contains valid data.
   ^~~~~~
./sk.h:39:4: warning: unknown command tag name [-Wdocumentation-unknown-command]
 * @phc_index:        index of the PHC device.
   ^~~~~~~~~~
./sk.h:40:4: warning: unknown command tag name 'so'; did you mean 'sa'? 
[-Wdocumentation-unknown-command]
 * @so_timestamping:  supported time stamping modes.

(and many more instance of a missing @param)

or

In file included from ts2phc_slave.c:18:
In file included from ./config.h:29:
./interface.h:16:6: warning: 'IF_NAMESIZE' is not defined, evaluates to 0 
[-Wundef]
#if (IF_NAMESIZE > MAX_IFNAME_SIZE)
     ^
or

config.c:600:16: warning: variable 'df' may be uninitialized when used here 
[-Wconditional-uninitialized]
                dst->val.d = df;
                             ^~
config.c:535:11: note: initialize the variable 'df' to silence this warning
        double df;
                 ^
                  = 0.0

Maybe it is worth to enable some of those additional warnings and check if they
do detect some real issues?

Kind regards,
Marian

Attachment: pgpA49iYfJdG_.pgp
Description: OpenPGP digital signature

_______________________________________________
Linuxptp-users mailing list
Linuxptp-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-users

Reply via email to