mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-08 10:04:42 +00:00
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:
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user