dm: hw: Replace sprintf with snprintf

Replace function sprintf with snprintf in device model

Tracked-On: #2079
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Long Liu
2018-12-12 07:19:17 +00:00
committed by wenlingz
parent 69dc939243
commit eab7cd47ae
2 changed files with 10 additions and 4 deletions

View File

@@ -178,7 +178,7 @@ static inline int valid_param(uint32_t m_off, uint32_t m_num)
*/
static int pci_npk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
{
int i, b, s, f, fd, ret, error = -1;
int i, b, s, f, fd, ret, rc, error = -1;
DIR *dir;
struct dirent *dent;
char name[PATH_MAX];
@@ -239,7 +239,10 @@ static int pci_npk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
}
/* read the host NPK configuration space */
sprintf(name, "%s/%s/config", NPK_DRV_SYSFS_PATH, dent->d_name);
rc = snprintf(name, PATH_MAX, "%s/%s/config", NPK_DRV_SYSFS_PATH,
dent->d_name);
if (rc > PATH_MAX)
WPRINTF(("NPK device name too long\n"));
fd = open(name, O_RDONLY);
if (fd == -1) {
WPRINTF(("Cannot open host NPK config\n"));