Commit a5b76fdb authored by Yonglong Liu's avatar Yonglong Liu Committed by Hao Chen
Browse files

net: hns3: fix snprintf() is printing too much problem

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAQ6G2



----------------------------------------------------------------------

smatch report a error:
hisi_ptp_create_clock() error: snprintf() is printing too much 32 vs 16

The PTP_CLOCK_NAME_LEN is not define in some kernel version, and the old
kernel is defined as 16, new kernel is defined as 32, so report this
error. Use sizeof() to fix it.

Fixes: c64545e1 ("net: hns3: add support for Hisilicon ptp sync device")
Signed-off-by: default avatarYonglong Liu <liuyonglong@huawei.com>
Signed-off-by: default avatarHao Chen <chenhao418@huawei.com>
parent f3b30686
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -15,10 +15,6 @@
#include <linux/net_tstamp.h>
#include <linux/debugfs.h>

#ifndef PTP_CLOCK_NAME_LEN
#define PTP_CLOCK_NAME_LEN	32
#endif

#define HISI_PTP_VERSION	"22.10.2"

#define HISI_PTP_NAME		"hisi_ptp"
@@ -588,7 +584,7 @@ static int hisi_ptp_create_clock(struct hisi_ptp_pdev *ptp)
{
	dev_info(ptp->ptp_tx->dev, "register ptp clock\n");

	snprintf(ptp->info.name, PTP_CLOCK_NAME_LEN, "%s", HISI_PTP_NAME);
	snprintf(ptp->info.name, sizeof(ptp->info.name), "%s", HISI_PTP_NAME);
	ptp->info.owner = THIS_MODULE;
	ptp->info.adjfine = hisi_ptp_adjfine;
	ptp->info.adjtime = hisi_ptp_adjtime;