These functions do not modify their argument, so make it const for correctness.
Signed-off-by: Vladimir Oltean <olte...@gmail.com> --- util.c | 8 ++++---- util.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/util.c b/util.c index 113467d08b9f..cc4f11008be2 100644 --- a/util.c +++ b/util.c @@ -139,10 +139,10 @@ char *bin2str_impl(Octet *data, int len, char *buf, int buf_len) return buf; } -char *cid2str(struct ClockIdentity *id) +char *cid2str(const struct ClockIdentity *id) { static char buf[64]; - unsigned char *ptr = id->id; + const unsigned char *ptr = id->id; snprintf(buf, sizeof(buf), "%02x%02x%02x.%02x%02x.%02x%02x%02x", ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]); @@ -160,10 +160,10 @@ int count_char(const char *str, char c) return num; } -char *pid2str(struct PortIdentity *id) +char *pid2str(const struct PortIdentity *id) { static char buf[64]; - unsigned char *ptr = id->clockIdentity.id; + const unsigned char *ptr = id->clockIdentity.id; snprintf(buf, sizeof(buf), "%02x%02x%02x.%02x%02x.%02x%02x%02x-%hu", ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7], diff --git a/util.h b/util.h index 5a22c4a79401..37d5dcf21a9c 100644 --- a/util.h +++ b/util.h @@ -75,7 +75,7 @@ char *bin2str_impl(Octet *data, int len, char *buf, int buf_len); * @param id Clock idendtity to show. * @return Pointer to a static global buffer holding the result. */ -char *cid2str(struct ClockIdentity *id); +char *cid2str(const struct ClockIdentity *id); /** * Compare two clock identities for equality. @@ -107,7 +107,7 @@ int count_char(const char *str, char c); * @param id Port idendtity to show. * @return Pointer to a static global buffer holding the result. */ -char *pid2str(struct PortIdentity *id); +char *pid2str(const struct PortIdentity *id); char *portaddr2str(struct PortAddress *addr); -- 2.25.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel