Skip to contentSkip to conversation

fpga: Replace char * with const char * for filename

PATCH New tien.fong.chee at intel.com 3 participants 4 messages Feb 15, 2019 – Feb 20, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fpga: Replace char * with const char * for filename

From: Tien Fong Chee <[email protected]>

Ensure the string for filename is always constant, otherwise it can be corrupted by the writing.

---
 drivers/fpga/zynqpl.c |    3 ++-
 include/fpga.h        |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/fpga/zynqpl.c +2 -1
index 499310d..683cf14 100644
@@ -421,7 +421,8 @@ static int zynq_loadfs(xilinx_desc *desc, const void *buf, size_t bsize,
 	loff_t blocksize, actread;
 	loff_t pos = 0;
 	int fstype;
-	char *interface, *dev_part, *filename;
+	char *interface, *dev_part;
+	const char *filename;
 
 	blocksize = fsinfo->blocksize;
 	interface = fsinfo->interface;
include/fpga.h +1 -1
index 195f0bd..51de5c5 100644
@@ -41,7 +41,7 @@ typedef struct {                /* typedef fpga_desc */
 	unsigned int blocksize;
 	char *interface;
 	char *dev_part;
-	char *filename;
+	const char *filename;
 	int fstype;
 } fpga_fs_info;
 
Signature · 1 line
1.7.7.4
#1 lore raw

PATCH 1/1 fpga: Replace char * with const char * for filename

Quoted 4 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Ensure the string for filename is always constant, otherwise it can be corrupted by the writing.

Have you reach any issue with it?

Quoted 27 lines
---
 drivers/fpga/zynqpl.c |    3 ++-
 include/fpga.h        |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/fpga/zynqpl.c +2 -1
index 499310d..683cf14 100644
@@ -421,7 +421,8 @@ static int zynq_loadfs(xilinx_desc *desc, const void *buf, size_t bsize,
 	loff_t blocksize, actread;
 	loff_t pos = 0;
 	int fstype;
-	char *interface, *dev_part, *filename;
+	char *interface, *dev_part;
+	const char *filename;
 
 	blocksize = fsinfo->blocksize;
 	interface = fsinfo->interface;
include/fpga.h +0 -0
index 195f0bd..51de5c5 100644

include/fpga.h typedef struct { /* typedef fpga_desc */ · line 47

Quoted 8 lines
include/fpga.h +1 -1
@@ -41,7 +41,7 @@ typedef struct {                /* typedef fpga_desc */
 	unsigned int blocksize;
 	char *interface;
 	char *dev_part;
-	char *filename;
+	const char *filename;
 	int fstype;
 } fpga_fs_info;
 

Anyway looks good applied.

Thanks,
Michal

#2 lore raw

PATCH 1/1 fpga: Replace char * with const char * for filename

Quoted 8 lines · Michal Simek
Quoted 6 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Ensure the string for filename is always constant, otherwise it can be
corrupted by the writing.

Have you reach any issue with it?

Just to resolve the compiler warning about missing of const.

Quoted 43 lines
Quoted 35 lines

---
 drivers/fpga/zynqpl.c |    3 ++-
 include/fpga.h        |    2 +-

 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/fpga/zynqpl.c +2 -1
index 499310d..683cf14 100644
@@ -421,7 +421,8 @@ static int zynq_loadfs(xilinx_desc *desc, const
 void *buf, size_t bsize,
  	loff_t blocksize, actread;
  	loff_t pos = 0;
  	int fstype;
-	char *interface, *dev_part, *filename;
+	char *interface, *dev_part;
+	const char *filename;


  blocksize = fsinfo->blocksize;
  interface = fsinfo->interface;

include/fpga.h +0 -0
index 195f0bd..51de5c5 100644
@@ -41,7 +41,7 @@ typedef struct {                /* typedef

fpga_desc */
  unsigned int blocksize;
  char *interface;
  char *dev_part;

include/fpga.h +1 -1
-	char *filename;
+	const char *filename;
Quoted 4 lines

  int fstype;
 } fpga_fs_info;

Anyway looks good applied.

Thanks,
Michal

#3 lore raw

PATCH 1/1 fpga: Replace char * with const char * for filename

Quoted 10 lines · Tien Fong
Quoted 8 lines · Michal Simek
Quoted 6 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Ensure the string for filename is always constant, otherwise it can be
corrupted by the writing.

Have you reach any issue with it?

Just to resolve the compiler warning about missing of const.

ok.

Thanks,
Michal