[PATCH rtems] grlib: Fix snprintf() overflow warnings from gcc 12

Joel Sherrill joel at rtems.org
Fri Jan 27 23:56:51 UTC 2023


Updates #4662.
---
 bsps/include/grlib/gpiolib.h           | 2 +-
 bsps/shared/grlib/1553/b1553brm.c      | 2 +-
 bsps/shared/grlib/1553/b1553rt.c       | 2 +-
 bsps/shared/grlib/analog/gradcdac.c    | 2 +-
 bsps/shared/grlib/can/grcan_internal.h | 2 +-
 bsps/shared/grlib/can/occan.c          | 2 +-
 bsps/shared/grlib/gpio/grgpio.c        | 4 ++--
 bsps/shared/grlib/i2c/i2cmst.c         | 2 +-
 bsps/shared/grlib/pwm/grpwm.c          | 2 +-
 bsps/shared/grlib/spi/spictrl.c        | 2 +-
 bsps/shared/grlib/spw/grspw.c          | 2 +-
 bsps/shared/grlib/tmtc/grtc.c          | 2 +-
 bsps/shared/grlib/tmtc/grtm.c          | 2 +-
 bsps/shared/grlib/uart/apbuart_cons.c  | 2 +-
 14 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/bsps/include/grlib/gpiolib.h b/bsps/include/grlib/gpiolib.h
index 61f6fc9..c0f865f 100644
--- a/bsps/include/grlib/gpiolib.h
+++ b/bsps/include/grlib/gpiolib.h
@@ -78,7 +78,7 @@ extern int gpiolib_irq_register(void *handle, void *func, void *arg);
 /*** Driver Interface ***/
 
 struct gpiolib_info {
-	char		devName[64];
+	char		devName[80];
 };
 
 struct gpiolib_drv_ops {
diff --git a/bsps/shared/grlib/1553/b1553brm.c b/bsps/shared/grlib/1553/b1553brm.c
index ee5f9fb..7e0b992 100644
--- a/bsps/shared/grlib/1553/b1553brm.c
+++ b/bsps/shared/grlib/1553/b1553brm.c
@@ -119,7 +119,7 @@ struct irq_log_list {
 typedef struct { 
 
 	struct drvmgr_dev *dev; /* Driver manager device */
-	char devName[32]; /* Device Name */
+	char devName[52]; /* Device Name */
 	struct brm_reg *regs;
 
 	unsigned int memarea_base;
diff --git a/bsps/shared/grlib/1553/b1553rt.c b/bsps/shared/grlib/1553/b1553rt.c
index 43bbeaa..7a4e2535 100644
--- a/bsps/shared/grlib/1553/b1553rt.c
+++ b/bsps/shared/grlib/1553/b1553rt.c
@@ -87,7 +87,7 @@ static rtems_driver_address_table b1553rt_driver = RT_DRIVER_TABLE_ENTRY;
 typedef struct { 
 
     struct drvmgr_dev *dev; /* Driver manager device */
-    char devName[32];     /* Device Name */
+    char devName[52];       /* Device Name */
 
     struct rt_reg *regs;
     unsigned int ctrl_copy; /* Local copy of config register */
diff --git a/bsps/shared/grlib/analog/gradcdac.c b/bsps/shared/grlib/analog/gradcdac.c
index 3b1afa8..09f8760 100644
--- a/bsps/shared/grlib/analog/gradcdac.c
+++ b/bsps/shared/grlib/analog/gradcdac.c
@@ -53,7 +53,7 @@
 struct gradcdac_priv {
 	struct gradcdac_regs *regs;	/* Must be first */
 	struct drvmgr_dev *dev;
-	char devName[48];
+	char devName[54];               /* Must be at least 48 per names */
 
 	unsigned int freq;
 	int irqno;
diff --git a/bsps/shared/grlib/can/grcan_internal.h b/bsps/shared/grlib/can/grcan_internal.h
index 16aabba..d27476a 100644
--- a/bsps/shared/grlib/can/grcan_internal.h
+++ b/bsps/shared/grlib/can/grcan_internal.h
@@ -56,7 +56,7 @@ struct grcan_config {
 
 struct grcan_priv {
 	struct drvmgr_dev *dev;	/* Driver manager device */
-	char devName[32];	/* Device Name */
+	char devName[52];	/* Device Name */
 	unsigned int baseaddr, ram_base;
 	struct grcan_regs *regs;
 	int irq;
diff --git a/bsps/shared/grlib/can/occan.c b/bsps/shared/grlib/can/occan.c
index 51ffd07..a6b37ec 100644
--- a/bsps/shared/grlib/can/occan.c
+++ b/bsps/shared/grlib/can/occan.c
@@ -226,7 +226,7 @@ typedef struct {
 
 typedef struct {
 	struct drvmgr_dev *dev;
-	char devName[32];
+	char devName[52];
 	SPIN_DECLARE(devlock);
 
 	/* hardware shortcuts */
diff --git a/bsps/shared/grlib/gpio/grgpio.c b/bsps/shared/grlib/gpio/grgpio.c
index d579432..711293d 100644
--- a/bsps/shared/grlib/gpio/grgpio.c
+++ b/bsps/shared/grlib/gpio/grgpio.c
@@ -379,12 +379,12 @@ static int grgpio_gpiolib_get_info(void *handle, struct gpiolib_info *pinfo)
 		/* Failed to get prefix, make sure of a unique FS name
 		 * by using the driver minor.
 		 */
-		snprintf(pinfo->devName, 64, "/dev/grgpio%d/%d", dev->minor_drv, portnr);
+		snprintf(pinfo->devName, 80, "/dev/grgpio%d/%d", dev->minor_drv, portnr);
 	} else {
 		/* Got special prefix, this means we have a bus prefix
 		 * And we should use our "bus minor"
 		 */
-		snprintf(pinfo->devName, 64, "/dev/%sgrgpio%d/%d", prefix, dev->minor_bus, portnr);
+		snprintf(pinfo->devName, 80, "/dev/%sgrgpio%d/%d", prefix, dev->minor_bus, portnr);
 	}
 
 	return 0;
diff --git a/bsps/shared/grlib/i2c/i2cmst.c b/bsps/shared/grlib/i2c/i2cmst.c
index 68d4140..70c796b 100644
--- a/bsps/shared/grlib/i2c/i2cmst.c
+++ b/bsps/shared/grlib/i2c/i2cmst.c
@@ -375,7 +375,7 @@ int i2cmst_init3(struct drvmgr_dev *dev)
 {
 	gr_i2cmst_prv_t *priv;
 	char prefix[32];
-	char devName[32];
+	char devName[50];
 	int rc;
 
 	priv = (gr_i2cmst_prv_t *)dev->priv;
diff --git a/bsps/shared/grlib/pwm/grpwm.c b/bsps/shared/grlib/pwm/grpwm.c
index 22d0831..32d16a2 100644
--- a/bsps/shared/grlib/pwm/grpwm.c
+++ b/bsps/shared/grlib/pwm/grpwm.c
@@ -169,7 +169,7 @@ struct grpwm_regs {
 struct grpwm_priv {
 	struct drvmgr_dev	*dev;
 	struct grpwm_regs		*regs;
-	char				devName[32];
+	char				devName[52];
 	int				irq;
 	int				open;
 
diff --git a/bsps/shared/grlib/spi/spictrl.c b/bsps/shared/grlib/spi/spictrl.c
index d4b62a3..081d281 100644
--- a/bsps/shared/grlib/spi/spictrl.c
+++ b/bsps/shared/grlib/spi/spictrl.c
@@ -251,7 +251,7 @@ int spictrl_init3(struct drvmgr_dev *dev)
 {
 	struct spictrl_priv *priv;
 	char prefix[32];
-	char devName[32];
+	char devName[48];
 	int rc;
 
 	priv = (struct spictrl_priv *)dev->priv;
diff --git a/bsps/shared/grlib/spw/grspw.c b/bsps/shared/grlib/spw/grspw.c
index 15fc34f..80fb263 100644
--- a/bsps/shared/grlib/spw/grspw.c
+++ b/bsps/shared/grlib/spw/grspw.c
@@ -108,7 +108,7 @@ typedef struct {
 typedef struct {
    /* configuration parameters */ 
    struct drvmgr_dev *dev; /* Driver manager device */
-   char devName[32]; /* Device Name */
+   char devName[49]; /* Device Name */
    LEON3_SPACEWIRE_Regs_Map *regs;
    spw_config config;
 
diff --git a/bsps/shared/grlib/tmtc/grtc.c b/bsps/shared/grlib/tmtc/grtc.c
index f7c97c2..4cb9a06 100644
--- a/bsps/shared/grlib/tmtc/grtc.c
+++ b/bsps/shared/grlib/tmtc/grtc.c
@@ -241,7 +241,7 @@ struct grtc_frame_pool {
 
 struct grtc_priv {
 	struct drvmgr_dev		*dev;		/* Driver manager device */
-	char			devName[32];	/* Device Name */
+	char			devName[52];	/* Device Name */
 	struct grtc_regs	*regs;		/* TC Hardware Register MAP */
 	int			irq;		/* IRQ number of TC core */
 	SPIN_DECLARE(devlock);			/* spin-lock of registers */
diff --git a/bsps/shared/grlib/tmtc/grtm.c b/bsps/shared/grlib/tmtc/grtm.c
index f400696..a1b2a54 100644
--- a/bsps/shared/grlib/tmtc/grtm.c
+++ b/bsps/shared/grlib/tmtc/grtm.c
@@ -367,7 +367,7 @@ struct grtm_ring {
 
 struct grtm_priv {
 	struct drvmgr_dev	*dev;		/* Driver manager device */
-	char			devName[32];	/* Device Name */
+	char			devName[52];	/* Device Name */
 	struct grtm_regs	*regs;
 	int			irq;
 	int			minor;
diff --git a/bsps/shared/grlib/uart/apbuart_cons.c b/bsps/shared/grlib/uart/apbuart_cons.c
index e5f41f4..5d47b7f 100644
--- a/bsps/shared/grlib/uart/apbuart_cons.c
+++ b/bsps/shared/grlib/uart/apbuart_cons.c
@@ -76,7 +76,7 @@ struct apbuart_priv {
 	struct drvmgr_dev *dev;
 	struct apbuart_regs *regs;
 	struct rtems_termios_tty *tty;
-	char devName[32];
+	char devName[52];
 	volatile int sending;
 	int mode;
 	int cap;
-- 
1.8.3.1



More information about the devel mailing list