@@ -8,6 +8,8 @@
#include <sys/mman.h>
#include <unistd.h>
+#include <rte_errno.h>
+
#include "roc_api.h"
#include "roc_priv.h"
@@ -1303,6 +1305,7 @@ dev_vf_hwcap_update(struct plt_pci_device *pci_dev, struct dev *dev)
static uintptr_t
cn20k_pfvf_mbox_alloc(struct dev *dev, uint16_t max_vfs)
{
+ char errmsg[RTE_STRERR_BUFSIZE];
char name[PLT_MEMZONE_NAMESIZE];
const struct plt_memzone *mz;
uint32_t vf_mbox_region;
@@ -1313,7 +1316,9 @@ cn20k_pfvf_mbox_alloc(struct dev *dev, uint16_t max_vfs)
mz = plt_memzone_reserve_aligned(name, vf_mbox_region, 0, MBOX_SIZE);
if (!mz) {
- plt_err("Memory alloc failed: %s", strerror(errno));
+ if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0)
+ snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno);
+ plt_err("Memory alloc failed: %s", errmsg);
goto fail;
}
@@ -1397,6 +1402,7 @@ dev_setup_shared_lmt_region(struct mbox *mbox, bool valid_iova, uint64_t iova)
static int
dev_lmt_setup(struct dev *dev)
{
+ char errmsg[RTE_STRERR_BUFSIZE];
char name[PLT_MEMZONE_NAMESIZE];
const struct plt_memzone *mz;
struct idev_cfg *idev;
@@ -1435,7 +1441,9 @@ dev_lmt_setup(struct dev *dev)
*/
mz = plt_lmt_region_reserve_aligned(name, LMT_REGION_SIZE, LMT_REGION_SIZE);
if (!mz) {
- plt_err("Memory alloc failed: %s", strerror(errno));
+ if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0)
+ snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno);
+ plt_err("Memory alloc failed: %s", errmsg);
goto fail;
}
@@ -6,6 +6,8 @@
#include <fcntl.h>
#include <unistd.h>
+#include <rte_errno.h>
+
#include "roc_api.h"
#include "roc_priv.h"
@@ -149,6 +151,7 @@ static int
cn10k_part_pass_get(uint32_t *part, uint32_t *pass)
{
#define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
+ char errmsg[RTE_STRERR_BUFSIZE];
char dirname[PATH_MAX];
struct dirent *e;
int ret = -1;
@@ -156,8 +159,9 @@ cn10k_part_pass_get(uint32_t *part, uint32_t *pass)
dir = opendir(SYSFS_PCI_DEVICES);
if (dir == NULL) {
- plt_err("%s(): opendir failed: %s", __func__,
- strerror(errno));
+ if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0)
+ snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno);
+ plt_err("%s(): opendir failed: %s", __func__, errmsg);
return -errno;
}