[PATCH 05/12] gr_rasta_io.c: Fix Unchecked return value from library (CID #1399763)

2021-03-04 Thread Ryan Long
CID 1399763: Unchecked return value from library in gr_rasta_io_init1().

Closes #4284
---
 bsps/shared/grlib/pci/gr_rasta_io.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bsps/shared/grlib/pci/gr_rasta_io.c 
b/bsps/shared/grlib/pci/gr_rasta_io.c
index f4c9d50..f93f73c 100644
--- a/bsps/shared/grlib/pci/gr_rasta_io.c
+++ b/bsps/shared/grlib/pci/gr_rasta_io.c
@@ -559,6 +559,7 @@ int gr_rasta_io_init1(struct drvmgr_dev *dev)
uint32_t bar0, bar1, bar0_size, bar1_size;
union drvmgr_key_value *value;
int resources_cnt;
+   int sc;
 
priv = grlib_calloc(1, sizeof(*priv));
if ( !priv )
@@ -574,7 +575,8 @@ int gr_rasta_io_init1(struct drvmgr_dev *dev)
 
strcpy(priv->prefix, "/dev/rastaio0");
priv->prefix[12] += dev->minor_drv;
-   mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   sc = mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   _Assert_Unused_variable_equals(sc, 0);
priv->prefix[13] = '/';
priv->prefix[14] = '\0';
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 06/12] gr_leon4_n2x.c: Fix Unchecked return value from library (CID #1399767)

2021-03-04 Thread Ryan Long
CID 1399767: Unchecked return value error from library in 
gr_cpci_leon4_n2x_init1().

Closes #4285
---
 bsps/sparc/shared/pci/gr_leon4_n2x.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bsps/sparc/shared/pci/gr_leon4_n2x.c 
b/bsps/sparc/shared/pci/gr_leon4_n2x.c
index 9baf73e..af7a5d7 100644
--- a/bsps/sparc/shared/pci/gr_leon4_n2x.c
+++ b/bsps/sparc/shared/pci/gr_leon4_n2x.c
@@ -478,6 +478,7 @@ int gr_cpci_leon4_n2x_init1(struct drvmgr_dev *dev)
int status, i;
union drvmgr_key_value *value;
int resources_cnt;
+   int sc;
 
priv = dev->priv;
if (!priv)
@@ -494,7 +495,8 @@ int gr_cpci_leon4_n2x_init1(struct drvmgr_dev *dev)
 
strcpy(priv->prefix, "/dev/leon4n2x0");
priv->prefix[13] += dev->minor_drv;
-   mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   sc = mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   _Assert_Unused_variable_equals(sc, 0);
priv->prefix[14] = '/';
priv->prefix[15] = '\0';
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 07/12] gr_rasta_tmtc.c: Fix Unchecked return value from library (CID #1399771)

2021-03-04 Thread Ryan Long
CID 1399771: Unchecked return value from library in gr_rasta_tmtc_init1().

Closes #4286
---
 bsps/shared/grlib/pci/gr_rasta_tmtc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bsps/shared/grlib/pci/gr_rasta_tmtc.c 
b/bsps/shared/grlib/pci/gr_rasta_tmtc.c
index bef2927..ccd1df4 100644
--- a/bsps/shared/grlib/pci/gr_rasta_tmtc.c
+++ b/bsps/shared/grlib/pci/gr_rasta_tmtc.c
@@ -574,6 +574,7 @@ int gr_rasta_tmtc_init1(struct drvmgr_dev *dev)
uint32_t bar0, bar1, bar0_size, bar1_size;
union drvmgr_key_value *value;
int resources_cnt;
+   int sc;
 
priv = dev->priv;
if (!priv)
@@ -587,7 +588,8 @@ int gr_rasta_tmtc_init1(struct drvmgr_dev *dev)
 
strcpy(priv->prefix, "/dev/rastatmtc0");
priv->prefix[14] += dev->minor_drv;
-   mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   sc = mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   _Assert_Unused_variable_equals(sc, 0);
priv->prefix[15] = '/';
priv->prefix[16] = '\0';
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 08/12] gr_rasta_tmtc.c: Fix Unchecked return value from library (CID #1399780)

2021-03-04 Thread Ryan Long
CID 1399780: Unchecked return value from library in gr_rasta_adcdac_init1().

Closes #4287
---
 bsps/shared/grlib/pci/gr_rasta_adcdac.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bsps/shared/grlib/pci/gr_rasta_adcdac.c 
b/bsps/shared/grlib/pci/gr_rasta_adcdac.c
index 12e35ac..9054967 100644
--- a/bsps/shared/grlib/pci/gr_rasta_adcdac.c
+++ b/bsps/shared/grlib/pci/gr_rasta_adcdac.c
@@ -380,6 +380,7 @@ int gr_rasta_adcdac_init1(struct drvmgr_dev *dev)
uint32_t bar0, bar1, bar0_size, bar1_size;
union drvmgr_key_value *value;
int resources_cnt;
+   int sc;
 
priv = grlib_calloc(1, sizeof(*priv));
if ( !priv )
@@ -395,7 +396,8 @@ int gr_rasta_adcdac_init1(struct drvmgr_dev *dev)
 
strcpy(priv->prefix, "/dev/rastaadcdac0");
priv->prefix[16] += dev->minor_drv;
-   mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   sc = mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   _Assert_Unused_variable_equals(sc, 0);
priv->prefix[17] = '/';
priv->prefix[18] = '\0';
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 09/12] gr_701.c: Unchecked return value from library (CID #1399783)

2021-03-04 Thread Ryan Long
CID 1399783: Unchecked return value from library in gr701_init1().

Closes #4288
---
 bsps/shared/grlib/pci/gr_701.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bsps/shared/grlib/pci/gr_701.c b/bsps/shared/grlib/pci/gr_701.c
index c9ac0db..25dc680 100644
--- a/bsps/shared/grlib/pci/gr_701.c
+++ b/bsps/shared/grlib/pci/gr_701.c
@@ -316,6 +316,7 @@ int gr701_init1(struct drvmgr_dev *dev)
struct pci_dev_info *devinfo;
uint32_t bar0, bar1, bar0_size, bar1_size;
int resources_cnt;
+   int sc;
 
priv = grlib_calloc(1, sizeof(*priv));
if ( !priv )
@@ -330,7 +331,8 @@ int gr701_init1(struct drvmgr_dev *dev)
/* Generate Device prefix */
strcpy(priv->prefix, "/dev/gr701_0");
priv->prefix[11] += dev->minor_drv;
-   mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   sc = mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   _Assert_Unused_variable_equals(sc, 0);
priv->prefix[12] = '/';
priv->prefix[13] = '\0';
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 10/12] gr_tmtc_1553.c: Unchecked return value from library (CID #1399785)

2021-03-04 Thread Ryan Long
CID 1399785: Unchecked return value from library in gr_tmtc_1553_init1().

Closes #4289
---
 bsps/shared/grlib/pci/gr_tmtc_1553.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bsps/shared/grlib/pci/gr_tmtc_1553.c 
b/bsps/shared/grlib/pci/gr_tmtc_1553.c
index ce02b8a..55a6358 100644
--- a/bsps/shared/grlib/pci/gr_tmtc_1553.c
+++ b/bsps/shared/grlib/pci/gr_tmtc_1553.c
@@ -291,6 +291,7 @@ int gr_tmtc_1553_init1(struct drvmgr_dev *dev)
int status;
uint32_t bar0, bar0_size;
int resources_cnt;
+   int sc;
 
/* PCI device does not have the IRQ line register, when PCI autoconf 
configures it the configuration
 * is forgotten. We take the IRQ number from the PCI Host device (AMBA 
device), this works as long
@@ -314,7 +315,8 @@ int gr_tmtc_1553_init1(struct drvmgr_dev *dev)
 
strcpy(priv->prefix, "/dev/tmtc1553_0");
priv->prefix[14] += dev->minor_drv;
-   mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   sc = mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   _Assert_Unused_variable_equals(sc, 0);
priv->prefix[15] = '/';
priv->prefix[16] = '\0';
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 12/12] main_help.c: Unchecked return value from library (CID #1437650)

2021-03-04 Thread Ryan Long
CID 1437650: Unchecked return value from library in rtems_shell_help().

Closes #4291
---
 cpukit/libmisc/shell/main_help.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cpukit/libmisc/shell/main_help.c b/cpukit/libmisc/shell/main_help.c
index 611f2e0..c76139e 100644
--- a/cpukit/libmisc/shell/main_help.c
+++ b/cpukit/libmisc/shell/main_help.c
@@ -119,7 +119,8 @@ static int rtems_shell_help(
 rtems_shell_cmd_t *shell_cmd;
 
 if (lines && (line > lines)) {
-  printf("Press any key to continue...");getchar();
+  printf("Press any key to continue...");
+  (void)getchar(); // we only want to know a character was pressed
   printf("\n");
   line = 0;
 }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 11/12] gr_cpci_gr740.c: Unchecked return value from library (CID #1437630)

2021-03-04 Thread Ryan Long
CID 1437630: Unchecked return value from library in gr_cpci_gr740_init1().

Closes #4290
---
 bsps/sparc/shared/pci/gr_cpci_gr740.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bsps/sparc/shared/pci/gr_cpci_gr740.c 
b/bsps/sparc/shared/pci/gr_cpci_gr740.c
index 95f5b94..96cb219 100644
--- a/bsps/sparc/shared/pci/gr_cpci_gr740.c
+++ b/bsps/sparc/shared/pci/gr_cpci_gr740.c
@@ -455,6 +455,7 @@ int gr_cpci_gr740_init1(struct drvmgr_dev *dev)
int status, i;
union drvmgr_key_value *value;
int resources_cnt;
+   int sc;
 
priv = dev->priv;
if (!priv)
@@ -471,7 +472,8 @@ int gr_cpci_gr740_init1(struct drvmgr_dev *dev)
 
strcpy(priv->prefix, "/dev/gr740_0");
priv->prefix[11] += dev->minor_drv;
-   mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   sc = mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
+   _Assert_Unused_variable_equals(sc, 0);
priv->prefix[12] = '/';
priv->prefix[13] = '\0';
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 00/12] Fix Unchecked return value from library errors

2021-03-04 Thread Ryan Long
Hi,

Here are the fixes for the "Unchecked return value from library"
Coverity errors. For most of these, I added a status code variable,
returned the value, and used the _Assert_Unused_variable_equal/unequal
macros. For main_help.c, a (void) was just added because we don't care
about the value that is returned.

Ryan

Ryan Long (12):
  gen_uuid.c: Fix two Unchecked return value from library errors
  main_chmod.c: Fix Unchecked return value from library (CID #1063856)
  pwdgrp.c: Fix Unchecked return value from library (CID #1255518)
  gr_rasta_spw_router.c: Fix Unchecked return value from library (CID
#1399760)
  gr_rasta_io.c: Fix Unchecked return value from library (CID #1399763)
  gr_leon4_n2x.c: Fix Unchecked return value from library (CID #1399767)
  gr_rasta_tmtc.c: Fix Unchecked return value from library (CID
#1399771)
  gr_rasta_tmtc.c: Fix Unchecked return value from library (CID
#1399780)
  gr_701.c: Unchecked return value from library (CID #1399783)
  gr_tmtc_1553.c: Unchecked return value from library (CID #1399785)
  gr_cpci_gr740.c: Unchecked return value from library (CID #1437630)
  main_help.c: Unchecked return value from library (CID #1437650)

 bsps/shared/grlib/pci/gr_701.c  |  4 +++-
 bsps/shared/grlib/pci/gr_rasta_adcdac.c |  4 +++-
 bsps/shared/grlib/pci/gr_rasta_io.c |  4 +++-
 bsps/shared/grlib/pci/gr_rasta_spw_router.c |  4 +++-
 bsps/shared/grlib/pci/gr_rasta_tmtc.c   |  4 +++-
 bsps/shared/grlib/pci/gr_tmtc_1553.c|  4 +++-
 bsps/sparc/shared/pci/gr_cpci_gr740.c   |  4 +++-
 bsps/sparc/shared/pci/gr_leon4_n2x.c|  4 +++-
 cpukit/libcsupport/src/pwdgrp.c |  6 +-
 cpukit/libmisc/shell/main_chmod.c   |  5 -
 cpukit/libmisc/shell/main_help.c|  3 ++-
 cpukit/libmisc/uuid/gen_uuid.c  | 12 ++--
 12 files changed, 45 insertions(+), 13 deletions(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 01/12] gen_uuid.c: Fix two Unchecked return value from library errors

2021-03-04 Thread Ryan Long
CID 1049146: Unchecked return value from library in get_clock().
CID 1049147: Unchecked return value from library in get_random_fd().

Closes #4280
---
 cpukit/libmisc/uuid/gen_uuid.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/cpukit/libmisc/uuid/gen_uuid.c b/cpukit/libmisc/uuid/gen_uuid.c
index 3ca75a0..0f2aba0 100644
--- a/cpukit/libmisc/uuid/gen_uuid.c
+++ b/cpukit/libmisc/uuid/gen_uuid.c
@@ -155,6 +155,7 @@ static int get_random_fd(void)
struct timeval  tv;
static int  fd = -2;
int i;
+   int sc;
 
if (fd == -2) {
gettimeofday(, 0);
@@ -165,7 +166,12 @@ static int get_random_fd(void)
if (fd >= 0) {
i = fcntl(fd, F_GETFD);
if (i >= 0)
-   fcntl(fd, F_SETFD, i | FD_CLOEXEC);
+   #ifdef __rtems__
+   sc = fcntl(fd, F_SETFD, i | FD_CLOEXEC);
+   _Assert_Unused_variable_unequal(sc, -1);
+   #else
+   fcntl(fd, F_SETFD, i | FD_CLOEXEC);
+   #endif
}
 #endif
srand((getpid() << ((sizeof(pid_t)*CHAR_BIT)>>1)) ^ getuid() ^ 
tv.tv_sec ^ tv.tv_usec);
@@ -334,6 +340,7 @@ static int get_clock(uint32_t *clock_high, uint32_t 
*clock_low,
uint64_tclock_reg;
mode_t  save_umask;
int len;
+   int sc;
 
if (state_fd == -2) {
save_umask = umask(0);
@@ -426,7 +433,8 @@ try_again:
}
rewind(state_f);
fl.l_type = F_UNLCK;
-   fcntl(state_fd, F_SETLK, );
+   sc = fcntl(state_fd, F_SETLK, );
+   _Assert_Unused_variable_unequal(sc, -1);
}
 
*clock_high = clock_reg >> 32;
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 02/12] main_chmod.c: Fix Unchecked return value from library (CID #1063856)

2021-03-04 Thread Ryan Long
CID 1063856: Unchecked return value from library in
rtems_shell_main_chmod().

Closes #4281
---
 cpukit/libmisc/shell/main_chmod.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cpukit/libmisc/shell/main_chmod.c 
b/cpukit/libmisc/shell/main_chmod.c
index 0c39072..df18ef1 100644
--- a/cpukit/libmisc/shell/main_chmod.c
+++ b/cpukit/libmisc/shell/main_chmod.c
@@ -34,6 +34,7 @@ static int rtems_shell_main_chmod(
   int   n;
   mode_tmode;
   unsigned long tmp;
+  int   sc; 
 
   if (argc < 2) {
 fprintf(stderr,"%s: too few arguments\n", argv[0]);
@@ -53,7 +54,9 @@ static int rtems_shell_main_chmod(
*  Now change the files modes
*/
   for (n=2 ; n < argc ; n++)
-chmod(argv[n++], mode);
+sc = chmod(argv[n++], mode);
+_Assert_Unused_variable_unequal(sc, -1);
+
 
   return 0;
 }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 0/3] Fix Unchecked return value Coverity errors upstream

2021-03-01 Thread Ryan Long
Hi,

These are patches for the third party Coverity issues. I forgot to
include them with the other patch last week. The only file that I used
the _Assert_Unused_variable_equals() macro with was grspw.c. The others, I just 
used (void) to "use" them.

Thanks,
Ryan

Ryan Long (3):
  fdt_rw.c: Fix Unchecked return value (CID #1047324)
  grspw.c: Fix Unchecked return value (CID #1399781)
  main_edit.c: Fix Unchecked return value (CID #1255318)

 bsps/shared/grlib/spw/grspw.c| 7 +--
 cpukit/dtc/libfdt/fdt_rw.c   | 6 +-
 cpukit/libmisc/shell/main_edit.c | 6 +-
 3 files changed, 15 insertions(+), 4 deletions(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 1/3] fdt_rw.c: Fix Unchecked return value (CID #1047324)

2021-03-01 Thread Ryan Long
CID 1047324: Unchecked return value in fdt_add_subnode_namelen().

Updates #4256
---
 cpukit/dtc/libfdt/fdt_rw.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cpukit/dtc/libfdt/fdt_rw.c b/cpukit/dtc/libfdt/fdt_rw.c
index 1385425..d6f7d93 100644
--- a/cpukit/dtc/libfdt/fdt_rw.c
+++ b/cpukit/dtc/libfdt/fdt_rw.c
@@ -348,7 +348,11 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
return offset;
 
/* Try to place the new node after the parent's properties */
-   fdt_next_tag(fdt, parentoffset, ); /* skip the BEGIN_NODE */
+#ifdef __rtems__
+ (void)fdt_next_tag(fdt, parentoffset, ); /* skip the 
BEGIN_NODE */
+#else
+  fdt_next_tag(fdt, parentoffset, );
+#endif
do {
offset = nextoffset;
tag = fdt_next_tag(fdt, offset, );
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/3] grspw.c: Fix Unchecked return value (CID #1399781)

2021-03-01 Thread Ryan Long
CID 1399781: Unchecked return value in grspw_device_init().

Closes #4259
---
 bsps/shared/grlib/spw/grspw.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/bsps/shared/grlib/spw/grspw.c b/bsps/shared/grlib/spw/grspw.c
index 1b50cc6..74a0fc7 100644
--- a/bsps/shared/grlib/spw/grspw.c
+++ b/bsps/shared/grlib/spw/grspw.c
@@ -465,6 +465,7 @@ int grspw_device_init(GRSPW_DEV *pDev)
struct amba_dev_info *ambadev;
struct ambapp_core *pnpinfo;
union drvmgr_key_value *value;
+rtems_status_code status;
 
/* Get device information from AMBA PnP information */
ambadev = (struct amba_dev_info *)pDev->dev->businfo;
@@ -555,21 +556,23 @@ int grspw_device_init(GRSPW_DEV *pDev)
return RTEMS_NO_MEMORY;
 
/* Create semaphores */
-   rtems_semaphore_create(
+   status = rtems_semaphore_create(
rtems_build_name('T', 'x', 'S', '0' + pDev->minor), 
0, 
RTEMS_FIFO | RTEMS_SIMPLE_BINARY_SEMAPHORE | 
RTEMS_NO_INHERIT_PRIORITY | \
RTEMS_NO_PRIORITY_CEILING, 
0, 
&(pDev->txsp));
+_Assert_Unused_variable_equals(status,RTEMS_SUCCESSFUL);
 
-   rtems_semaphore_create(
+   status = rtems_semaphore_create(
rtems_build_name('R', 'x', 'S', '0' + pDev->minor), 
0, 
RTEMS_FIFO | RTEMS_SIMPLE_BINARY_SEMAPHORE | 
RTEMS_NO_INHERIT_PRIORITY | \
RTEMS_NO_PRIORITY_CEILING, 
0, 
&(pDev->rxsp));
+_Assert_Unused_variable_equals(status,RTEMS_SUCCESSFUL);
 
grspw_hw_init(pDev);
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 3/3] main_edit.c: Fix Unchecked return value (CID #1255318)

2021-03-01 Thread Ryan Long
CID 1255318: Unchecked return value in display_line().

Updates #4257
---
 cpukit/libmisc/shell/main_edit.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cpukit/libmisc/shell/main_edit.c b/cpukit/libmisc/shell/main_edit.c
index a011049..8730b21 100644
--- a/cpukit/libmisc/shell/main_edit.c
+++ b/cpukit/libmisc/shell/main_edit.c
@@ -1089,7 +1089,11 @@ static void display_line(struct editor *ed, int pos, int 
fullline) {
   int selstart, selend, ch;
   char *s;
 
-  get_selection(ed, , );
+  #ifdef __rtems__
+(void)get_selection(ed, , );
+  #else
+get_selection(ed, , );
+  #endif
   while (col < maxcol) {
 if (margin == 0) {
   if (!hilite && pos >= selstart && pos < selend) {
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 0/3] Fix upstream Unchecked return value Coverity errors

2021-03-01 Thread Ryan Long
Hi,

Here are the patches with the suggested changes.

Thanks,
Ryan

Ryan Long (3):
  fdt_rw.c: Fix Unchecked return value (CID #1047324)
  grspw.c: Fix Unchecked return value (CID #1399781)
  main_edit.c: Fix Unchecked return value (CID #1255318)

 bsps/shared/grlib/spw/grspw.c| 7 +--
 cpukit/dtc/libfdt/fdt_rw.c   | 6 +-
 cpukit/libmisc/shell/main_edit.c | 6 +-
 3 files changed, 15 insertions(+), 4 deletions(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 2/3] grspw.c: Fix Unchecked return value (CID #1399781)

2021-03-01 Thread Ryan Long
CID 1399781: Unchecked return value in grspw_device_init().

Closes #4259
---
 bsps/shared/grlib/spw/grspw.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/bsps/shared/grlib/spw/grspw.c b/bsps/shared/grlib/spw/grspw.c
index 1b50cc6..32740d4 100644
--- a/bsps/shared/grlib/spw/grspw.c
+++ b/bsps/shared/grlib/spw/grspw.c
@@ -465,6 +465,7 @@ int grspw_device_init(GRSPW_DEV *pDev)
struct amba_dev_info *ambadev;
struct ambapp_core *pnpinfo;
union drvmgr_key_value *value;
+rtems_status_code status;
 
/* Get device information from AMBA PnP information */
ambadev = (struct amba_dev_info *)pDev->dev->businfo;
@@ -555,21 +556,23 @@ int grspw_device_init(GRSPW_DEV *pDev)
return RTEMS_NO_MEMORY;
 
/* Create semaphores */
-   rtems_semaphore_create(
+   status = rtems_semaphore_create(
rtems_build_name('T', 'x', 'S', '0' + pDev->minor), 
0, 
RTEMS_FIFO | RTEMS_SIMPLE_BINARY_SEMAPHORE | 
RTEMS_NO_INHERIT_PRIORITY | \
RTEMS_NO_PRIORITY_CEILING, 
0, 
&(pDev->txsp));
+_Assert_Unused_variable_equals(status, RTEMS_SUCCESSFUL);
 
-   rtems_semaphore_create(
+   status = rtems_semaphore_create(
rtems_build_name('R', 'x', 'S', '0' + pDev->minor), 
0, 
RTEMS_FIFO | RTEMS_SIMPLE_BINARY_SEMAPHORE | 
RTEMS_NO_INHERIT_PRIORITY | \
RTEMS_NO_PRIORITY_CEILING, 
0, 
&(pDev->rxsp));
+_Assert_Unused_variable_equals(status, RTEMS_SUCCESSFUL);
 
grspw_hw_init(pDev);
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 3/3] main_edit.c: Fix Unchecked return value (CID #1255318)

2021-03-01 Thread Ryan Long
CID 1255318: Unchecked return value in display_line().

Updates #4257
---
 cpukit/libmisc/shell/main_edit.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cpukit/libmisc/shell/main_edit.c b/cpukit/libmisc/shell/main_edit.c
index a011049..9819a94 100644
--- a/cpukit/libmisc/shell/main_edit.c
+++ b/cpukit/libmisc/shell/main_edit.c
@@ -1089,7 +1089,11 @@ static void display_line(struct editor *ed, int pos, int 
fullline) {
   int selstart, selend, ch;
   char *s;
 
-  get_selection(ed, , );
+  #ifdef __rtems__
+(void) get_selection(ed, , );
+  #else
+get_selection(ed, , );
+  #endif
   while (col < maxcol) {
 if (margin == 0) {
   if (!hilite && pos >= selstart && pos < selend) {
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 1/3] fdt_rw.c: Fix Unchecked return value (CID #1047324)

2021-03-01 Thread Ryan Long
CID 1047324: Unchecked return value in fdt_add_subnode_namelen().

Updates #4256
---
 cpukit/dtc/libfdt/fdt_rw.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cpukit/dtc/libfdt/fdt_rw.c b/cpukit/dtc/libfdt/fdt_rw.c
index 1385425..41abd8c 100644
--- a/cpukit/dtc/libfdt/fdt_rw.c
+++ b/cpukit/dtc/libfdt/fdt_rw.c
@@ -348,7 +348,11 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
return offset;
 
/* Try to place the new node after the parent's properties */
-   fdt_next_tag(fdt, parentoffset, ); /* skip the BEGIN_NODE */
+#ifdef __rtems__
+ (void) fdt_next_tag(fdt, parentoffset, ); /* skip the 
BEGIN_NODE */
+#else
+  fdt_next_tag(fdt, parentoffset, );
+#endif
do {
offset = nextoffset;
tag = fdt_next_tag(fdt, offset, );
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Checking Status of My Outstanding Patches

2021-03-05 Thread Ryan Long
Hi,

Since I've sent a lot of patches this week, I just want to verify which are 
ready to be merged and what needs to be resubmitted.

Ready to be merged:

Grlib patches:

  *   grspw.c
  *   gr_rasta_spw_router.c
  *   gr_rasta_tmtc.c
  *   gr_leon4_n2x.c
  *   gr_701.c
  *   gr_cpci_gr740.c
  *   satcan.c
  *   b1553brm.c
  *   grcan.c
  *   gr_rasta_adcdac.c (was accidentally labeled as gr_rasta_tmtc.c in commit 
message)
  *   gr_tmtc_1553.c
  *   grtc.c

Other:
Missing break in switch

 *   pci_cfg_read.c
 *   cpuusagetop.c

What needs to be resubmitted:

  *   Unchecked return value from library
 *   gen_uuid.c
 *   cpuusagetop.c
  *   Unchecked return value
 *   main_edit.c

Thanks,
Ryan
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH v2 0/4] Fix Unchecked return value from library issues

2021-03-05 Thread Ryan Long
Hi,

Here are the patches with the recommended fixes.

Thanks,
Ryan

Ryan Long (4):
  gen_uuid.c: Fix two Unchecked return value from library errors
  main_chmod.c: Fix Unchecked return value from library (CID #1063856)
  pwdgrp.c: Fix Unchecked return value from library (CID #1255518)
  main_help.c: Unchecked return value from library (CID #1437650)

 cpukit/libcsupport/src/pwdgrp.c   |  6 +-
 cpukit/libmisc/shell/main_chmod.c |  5 -
 cpukit/libmisc/shell/main_help.c  |  3 ++-
 cpukit/libmisc/uuid/gen_uuid.c| 11 ---
 4 files changed, 19 insertions(+), 6 deletions(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 1/4] gen_uuid.c: Fix two Unchecked return value from library errors

2021-03-05 Thread Ryan Long
CID 1049146: Unchecked return value from library in get_clock().
CID 1049147: Unchecked return value from library in get_random_fd().

Closes #4280
---
 cpukit/libmisc/uuid/gen_uuid.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/cpukit/libmisc/uuid/gen_uuid.c b/cpukit/libmisc/uuid/gen_uuid.c
index 3ca75a0..5bb34c0 100644
--- a/cpukit/libmisc/uuid/gen_uuid.c
+++ b/cpukit/libmisc/uuid/gen_uuid.c
@@ -155,6 +155,7 @@ static int get_random_fd(void)
struct timeval  tv;
static int  fd = -2;
int i;
+   int sc;
 
if (fd == -2) {
gettimeofday(, 0);
@@ -164,8 +165,10 @@ static int get_random_fd(void)
fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
if (fd >= 0) {
i = fcntl(fd, F_GETFD);
-   if (i >= 0)
-   fcntl(fd, F_SETFD, i | FD_CLOEXEC);
+   if (i >= 0) {
+   sc = fcntl(fd, F_SETFD, i | FD_CLOEXEC);
+   _Assert_Unused_variable_unequal(sc, -1);
+   }
}
 #endif
srand((getpid() << ((sizeof(pid_t)*CHAR_BIT)>>1)) ^ getuid() ^ 
tv.tv_sec ^ tv.tv_usec);
@@ -334,6 +337,7 @@ static int get_clock(uint32_t *clock_high, uint32_t 
*clock_low,
uint64_tclock_reg;
mode_t  save_umask;
int len;
+   int sc;
 
if (state_fd == -2) {
save_umask = umask(0);
@@ -426,7 +430,8 @@ try_again:
}
rewind(state_f);
fl.l_type = F_UNLCK;
-   fcntl(state_fd, F_SETLK, );
+   sc = fcntl(state_fd, F_SETLK, );
+   _Assert_Unused_variable_unequal(sc, -1);
}
 
*clock_high = clock_reg >> 32;
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 2/4] main_chmod.c: Fix Unchecked return value from library (CID #1063856)

2021-03-05 Thread Ryan Long
CID 1063856: Unchecked return value from library in
rtems_shell_main_chmod().

Closes #4281
---
 cpukit/libmisc/shell/main_chmod.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cpukit/libmisc/shell/main_chmod.c 
b/cpukit/libmisc/shell/main_chmod.c
index 0c39072..df18ef1 100644
--- a/cpukit/libmisc/shell/main_chmod.c
+++ b/cpukit/libmisc/shell/main_chmod.c
@@ -34,6 +34,7 @@ static int rtems_shell_main_chmod(
   int   n;
   mode_tmode;
   unsigned long tmp;
+  int   sc; 
 
   if (argc < 2) {
 fprintf(stderr,"%s: too few arguments\n", argv[0]);
@@ -53,7 +54,9 @@ static int rtems_shell_main_chmod(
*  Now change the files modes
*/
   for (n=2 ; n < argc ; n++)
-chmod(argv[n++], mode);
+sc = chmod(argv[n++], mode);
+_Assert_Unused_variable_unequal(sc, -1);
+
 
   return 0;
 }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 3/4] pwdgrp.c: Fix Unchecked return value from library (CID #1255518)

2021-03-05 Thread Ryan Long
CID 1255518: Unchecked return value from library in pwdgrp_init().

Closes #4282
---
 cpukit/libcsupport/src/pwdgrp.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cpukit/libcsupport/src/pwdgrp.c b/cpukit/libcsupport/src/pwdgrp.c
index a97d397..f4a10f7 100644
--- a/cpukit/libcsupport/src/pwdgrp.c
+++ b/cpukit/libcsupport/src/pwdgrp.c
@@ -36,6 +36,7 @@
 #include 
 
 #include 
+#include 
 
 #include "pwdgrp.h"
 
@@ -62,10 +63,13 @@ static void init_file(const char *name, const char *content)
  */
 static void pwdgrp_init(void)
 {
+  int sc;
+
   /*
* Do the best to create this directory.
*/
-  mkdir("/etc", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+  sc = mkdir("/etc", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+  _Assert_Unused_variable_equals(sc, 0);
 
   /*
*  Initialize /etc/passwd
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 4/4] main_help.c: Unchecked return value from library (CID #1437650)

2021-03-05 Thread Ryan Long
CID 1437650: Unchecked return value from library in rtems_shell_help().

Closes #4291
---
 cpukit/libmisc/shell/main_help.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cpukit/libmisc/shell/main_help.c b/cpukit/libmisc/shell/main_help.c
index 611f2e0..9f59e9d 100644
--- a/cpukit/libmisc/shell/main_help.c
+++ b/cpukit/libmisc/shell/main_help.c
@@ -119,7 +119,8 @@ static int rtems_shell_help(
 rtems_shell_cmd_t *shell_cmd;
 
 if (lines && (line > lines)) {
-  printf("Press any key to continue...");getchar();
+  printf("Press any key to continue...");
+  (void) getchar(); /* we only want to know a character was pressed */
   printf("\n");
   line = 0;
 }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v3 3/4] pwdgrp.c: Fix Unchecked return value from library (CID #1255518)

2021-03-05 Thread Ryan Long
CID 1255518: Unchecked return value from library in pwdgrp_init().

Closes #4282
---
 cpukit/libcsupport/src/pwdgrp.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cpukit/libcsupport/src/pwdgrp.c b/cpukit/libcsupport/src/pwdgrp.c
index a97d397..f4a10f7 100644
--- a/cpukit/libcsupport/src/pwdgrp.c
+++ b/cpukit/libcsupport/src/pwdgrp.c
@@ -36,6 +36,7 @@
 #include 
 
 #include 
+#include 
 
 #include "pwdgrp.h"
 
@@ -62,10 +63,13 @@ static void init_file(const char *name, const char *content)
  */
 static void pwdgrp_init(void)
 {
+  int sc;
+
   /*
* Do the best to create this directory.
*/
-  mkdir("/etc", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+  sc = mkdir("/etc", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+  _Assert_Unused_variable_equals(sc, 0);
 
   /*
*  Initialize /etc/passwd
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v3 1/4] gen_uuid.c: Fix two Unchecked return value from library errors

2021-03-05 Thread Ryan Long
CID 1049146: Unchecked return value from library in get_clock().
CID 1049147: Unchecked return value from library in get_random_fd().

Closes #4280
---
 cpukit/libmisc/uuid/gen_uuid.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/cpukit/libmisc/uuid/gen_uuid.c b/cpukit/libmisc/uuid/gen_uuid.c
index 3ca75a0..5bb34c0 100644
--- a/cpukit/libmisc/uuid/gen_uuid.c
+++ b/cpukit/libmisc/uuid/gen_uuid.c
@@ -155,6 +155,7 @@ static int get_random_fd(void)
struct timeval  tv;
static int  fd = -2;
int i;
+   int sc;
 
if (fd == -2) {
gettimeofday(, 0);
@@ -164,8 +165,10 @@ static int get_random_fd(void)
fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
if (fd >= 0) {
i = fcntl(fd, F_GETFD);
-   if (i >= 0)
-   fcntl(fd, F_SETFD, i | FD_CLOEXEC);
+   if (i >= 0) {
+   sc = fcntl(fd, F_SETFD, i | FD_CLOEXEC);
+   _Assert_Unused_variable_unequal(sc, -1);
+   }
}
 #endif
srand((getpid() << ((sizeof(pid_t)*CHAR_BIT)>>1)) ^ getuid() ^ 
tv.tv_sec ^ tv.tv_usec);
@@ -334,6 +337,7 @@ static int get_clock(uint32_t *clock_high, uint32_t 
*clock_low,
uint64_tclock_reg;
mode_t  save_umask;
int len;
+   int sc;
 
if (state_fd == -2) {
save_umask = umask(0);
@@ -426,7 +430,8 @@ try_again:
}
rewind(state_f);
fl.l_type = F_UNLCK;
-   fcntl(state_fd, F_SETLK, );
+   sc = fcntl(state_fd, F_SETLK, );
+   _Assert_Unused_variable_unequal(sc, -1);
}
 
*clock_high = clock_reg >> 32;
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v3 4/4] main_help.c: Unchecked return value from library (CID #1437650)

2021-03-05 Thread Ryan Long
CID 1437650: Unchecked return value from library in rtems_shell_help().

Closes #4291
---
 cpukit/libmisc/shell/main_help.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cpukit/libmisc/shell/main_help.c b/cpukit/libmisc/shell/main_help.c
index 611f2e0..9f59e9d 100644
--- a/cpukit/libmisc/shell/main_help.c
+++ b/cpukit/libmisc/shell/main_help.c
@@ -119,7 +119,8 @@ static int rtems_shell_help(
 rtems_shell_cmd_t *shell_cmd;
 
 if (lines && (line > lines)) {
-  printf("Press any key to continue...");getchar();
+  printf("Press any key to continue...");
+  (void) getchar(); /* we only want to know a character was pressed */
   printf("\n");
   line = 0;
 }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v3 2/4] main_chmod.c: Fix Unchecked return value from library (CID #1063856)

2021-03-05 Thread Ryan Long
CID 1063856: Unchecked return value from library in
rtems_shell_main_chmod().

Closes #4281
---
 cpukit/libmisc/shell/main_chmod.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/cpukit/libmisc/shell/main_chmod.c 
b/cpukit/libmisc/shell/main_chmod.c
index 0c39072..8b932fa 100644
--- a/cpukit/libmisc/shell/main_chmod.c
+++ b/cpukit/libmisc/shell/main_chmod.c
@@ -34,6 +34,7 @@ static int rtems_shell_main_chmod(
   int   n;
   mode_tmode;
   unsigned long tmp;
+  int   sc;
 
   if (argc < 2) {
 fprintf(stderr,"%s: too few arguments\n", argv[0]);
@@ -52,8 +53,10 @@ static int rtems_shell_main_chmod(
   /*
*  Now change the files modes
*/
-  for (n=2 ; n < argc ; n++)
-chmod(argv[n++], mode);
+  for (n=2 ; n < argc ; n++) {
+sc = chmod(argv[n++], mode);
+_Assert_Unused_variable_unequal(sc, -1);
+  }
 
   return 0;
 }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v3 0/4] Fix Unchecked return value from libarary

2021-03-05 Thread Ryan Long
Hi,

Here are the patches with the fix to main_chmod.c.

Thanks,
Ryan

Ryan Long (4):
  gen_uuid.c: Fix two Unchecked return value from library errors
  main_chmod.c: Fix Unchecked return value from library (CID #1063856)
  pwdgrp.c: Fix Unchecked return value from library (CID #1255518)
  main_help.c: Unchecked return value from library (CID #1437650)

 cpukit/libcsupport/src/pwdgrp.c   |  6 +-
 cpukit/libmisc/shell/main_chmod.c |  7 +--
 cpukit/libmisc/shell/main_help.c  |  3 ++-
 cpukit/libmisc/uuid/gen_uuid.c| 11 ---
 4 files changed, 20 insertions(+), 7 deletions(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] main_edit.c: Fix Unchecked return value (CID #1255318)

2021-03-05 Thread Ryan Long
CID 1255318: Unchecked return value in display_line().

Updates #4257
---
 cpukit/libmisc/shell/main_edit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/libmisc/shell/main_edit.c b/cpukit/libmisc/shell/main_edit.c
index a011049..8ac7eee 100644
--- a/cpukit/libmisc/shell/main_edit.c
+++ b/cpukit/libmisc/shell/main_edit.c
@@ -1089,7 +1089,7 @@ static void display_line(struct editor *ed, int pos, int 
fullline) {
   int selstart, selend, ch;
   char *s;
 
-  get_selection(ed, , );
+  (void) get_selection(ed, , );
   while (col < maxcol) {
 if (margin == 0) {
   if (!hilite && pos >= selstart && pos < selend) {
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] Fix Unchecked return value issue

2021-03-05 Thread Ryan Long
Hi,

Here's the fix for main_edit.c. I just just needed to add a space
between (void) and the function call.

Thanks,
Ryan

Ryan Long (1):
  main_edit.c: Fix Unchecked return value (CID #1255318)

 cpukit/libmisc/shell/main_edit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v5 0/4] Unused value Coverity issues

2021-04-07 Thread Ryan Long
Hi,

Here are the patches with the recommended changes.

Thanks,
Ryan

Ryan Long (4):
  main_cp.c: Unused value (CID #1255344)
  print-ls.c: Unused value (CID #1255346)
  fastlz.c: Unused value (CID #1399751)
  disp_hcms29xx.c: Unused value (CID #1399752)

 bsps/shared/dev/display/disp_hcms29xx.c |  4 +++-
 cpukit/libdl/fastlz.c   | 10 +-
 cpukit/libmisc/shell/main_cp.c  | 32 
 cpukit/libmisc/shell/print-ls.c |  9 +
 4 files changed, 53 insertions(+), 2 deletions(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v5 2/4] print-ls.c: Unused value (CID #1255346)

2021-04-07 Thread Ryan Long
CID 1255346: Unused value in rtems_shell_ls_printacol().

Closes #4340
---
 cpukit/libmisc/shell/print-ls.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/cpukit/libmisc/shell/print-ls.c b/cpukit/libmisc/shell/print-ls.c
index 15702b4..95a2cdf 100644
--- a/cpukit/libmisc/shell/print-ls.c
+++ b/cpukit/libmisc/shell/print-ls.c
@@ -325,7 +325,16 @@ printacol(rtems_shell_ls_globals* globals, DISPLAY *dp)
if (IS_NOPRINT(p))
continue;
if (col >= numcols) {
+   #ifdef __rtems__
+   /*
+* chcnt is not using the value that it has been assigned
+* before being used again, resulting in a Coverity issue.
+* See CID 1255346
+*/
+   col = 0;
+   #else
chcnt = col = 0;
+   #endif
(void)putchar('\n');
}
chcnt = printaname(globals, p, dp->s_inode,
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v5 1/4] main_cp.c: Unused value (CID #1255344)

2021-04-07 Thread Ryan Long
CID 1255344: Unused value in copy().

Closes #4339
---
 cpukit/libmisc/shell/main_cp.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/cpukit/libmisc/shell/main_cp.c b/cpukit/libmisc/shell/main_cp.c
index cddbc95..913ece1 100644
--- a/cpukit/libmisc/shell/main_cp.c
+++ b/cpukit/libmisc/shell/main_cp.c
@@ -310,11 +310,31 @@ copy(rtems_shell_cp_globals* cp_globals,
case FTS_ERR:
warnx("%s: %s",
curr->fts_path, strerror(curr->fts_errno));
+   #ifdef __rtems__
+   /*
+* Coverity spotted that badcp is set by each loop
+* iteration so setting it right before continue
+* results in the value being unused. See CID 1255344
+*
+* The current NetBSD source (v1.62) was checked and
+* the same issue appears to apply although the
+* variable names have changed since this was imported
+* to RTEMS.
+*
+* This pattern exists in multiple places in this file.
+*/
+   rval = 1;
+   #else
badcp = rval = 1;
+   #endif
continue;
case FTS_DC:/* Warn, continue. */
warnx("%s: directory causes a cycle", curr->fts_path);
+   #ifdef __rtems__
+   rval = 1;
+   #else
badcp = rval = 1;
+   #endif
continue;
default:
;
@@ -366,7 +386,11 @@ copy(rtems_shell_cp_globals* cp_globals,
if (target_mid - to.p_path + nlen >= PATH_MAX) {
warnx("%s%s: name too long (not copied)",
to.p_path, p);
+   #ifdef __rtems__
+   rval = 1;
+   #else
badcp = rval = 1;
+   #endif
continue;
}
(void)strncat(target_mid, p, nlen);
@@ -418,7 +442,11 @@ copy(rtems_shell_cp_globals* cp_globals,
to_stat.st_ino == curr->fts_statp->st_ino) {
warnx("%s and %s are identical (not copied).",
to.p_path, curr->fts_path);
+   #ifdef __rtems__
+   rval = 1;
+   #else
badcp = rval = 1;
+   #endif
if (S_ISDIR(curr->fts_statp->st_mode))
(void)fts_set(ftsp, curr, FTS_SKIP);
continue;
@@ -428,7 +456,11 @@ copy(rtems_shell_cp_globals* cp_globals,
warnx("cannot overwrite directory %s with "
"non-directory %s",
to.p_path, curr->fts_path);
+   #ifdef __rtems__
+   rval = 1;
+   #else
badcp = rval = 1;
+   #endif
continue;
}
dne = 0;
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v5 4/4] disp_hcms29xx.c: Unused value (CID #1399752)

2021-04-07 Thread Ryan Long
CID 1399752: Unused value in disp_hcms29xx_update_task().

Closes #4342
---
 bsps/shared/dev/display/disp_hcms29xx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bsps/shared/dev/display/disp_hcms29xx.c 
b/bsps/shared/dev/display/disp_hcms29xx.c
index 740aa56..5ad7063 100644
--- a/bsps/shared/dev/display/disp_hcms29xx.c
+++ b/bsps/shared/dev/display/disp_hcms29xx.c
@@ -23,6 +23,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -596,7 +597,8 @@ static rtems_task disp_hcms29xx_update_task
  (int) strlen(softc_ptr->disp_param.disp_buffer);
   }
   if (rc == RTEMS_SUCCESSFUL) {
-   rc = rtems_semaphore_release(softc_ptr->disp_param.trns_sema_id);
+rc = rtems_semaphore_release(softc_ptr->disp_param.trns_sema_id);
+_Assert_Unused_variable_equals(rc, RTEMS_SUCCESSFUL);
   }
   /*
* set initial offset to negative value
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v5 3/4] fastlz.c: Unused value (CID #1399751)

2021-04-07 Thread Ryan Long
CID 1399751: Unused value in fastlz2_compress().

Closes #4341
---
 cpukit/libdl/fastlz.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/cpukit/libdl/fastlz.c b/cpukit/libdl/fastlz.c
index 3c9d6f6..7257c98 100644
--- a/cpukit/libdl/fastlz.c
+++ b/cpukit/libdl/fastlz.c
@@ -219,7 +219,15 @@ static FASTLZ_INLINE int FASTLZ_COMPRESSOR(const void* 
input, int length, void*
 if(ip[0] == ip[-1] && FASTLZ_READU16(ip-1)==FASTLZ_READU16(ip+1))
 {
   distance = 1;
-  ip += 3;
+  #ifndef __rtems__
+/*
+ * ip is assigned a value here, but is immediately assigned another
+ * value when it goes to match (line 269). The value that was initially
+ * assigned is not used, and this results in a Coverity issue. See CID
+ * 1399751
+ */
+ip += 3;
+  #endif
   ref = anchor - 1 + 3;
   goto match;
 }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


RE: [PATCH 2/2] main_rtrace.c: Fix Dereference after null check (CID #1399709)

2021-04-14 Thread Ryan Long
ping

-Original Message-
From: Ryan Long  
Sent: Friday, March 12, 2021 8:56 AM
To: devel@rtems.org
Cc: Ryan Long 
Subject: [PATCH 2/2] main_rtrace.c: Fix Dereference after null check (CID 
#1399709)

CID 1399709: Dereference after null check in rtems_trace_buffering_shell_save().

Closes #4329
---
 cpukit/libmisc/shell/main_rtrace.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cpukit/libmisc/shell/main_rtrace.c 
b/cpukit/libmisc/shell/main_rtrace.c
index 753ab9d..e4f59c4 100644
--- a/cpukit/libmisc/shell/main_rtrace.c
+++ b/cpukit/libmisc/shell/main_rtrace.c
@@ -473,6 +473,7 @@ rtems_trace_buffering_shell_save (int argc, char *argv[])
   {
 close (out);
 printf ("error: no memory\n");
+return 1;
   }
 
   memset (buf, 0, SAVE_BUF_SIZE);
--
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 2/3] consolesimpletask.c: Fix Coverity Unchecked return value

2021-02-12 Thread Ryan Long
Fixes CID #1437625 and #1472765 where the return value of rtems_task_create and
rtems_task_start is discarded.

Fix file consolesimpletask.c
---
 cpukit/libcsupport/src/consolesimpletask.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/cpukit/libcsupport/src/consolesimpletask.c 
b/cpukit/libcsupport/src/consolesimpletask.c
index 82ea2a5..393de3a 100644
--- a/cpukit/libcsupport/src/consolesimpletask.c
+++ b/cpukit/libcsupport/src/consolesimpletask.c
@@ -217,6 +217,7 @@ static const char _Console_simple_task_Name[] = "console";
 void _Console_simple_task_Initialize( void )
 {
   Console_simple_task_Control *cons;
+  rtems_status_code status;
 
   cons = &_Console_simple_task_Instance;
 
@@ -233,7 +234,7 @@ void _Console_simple_task_Initialize( void )
 
   IMFS_add_node( "/dev", >Node, NULL );
 
-  rtems_task_create(
+  status = rtems_task_create(
 rtems_build_name('C', 'O', 'N', 'S'),
 RTEMS_MAXIMUM_PRIORITY - 1,
 RTEMS_MINIMUM_STACK_SIZE,
@@ -241,10 +242,12 @@ void _Console_simple_task_Initialize( void )
 RTEMS_DEFAULT_MODES,
 >task
   );
+  _Assert_Unused_variable_equals(status, RTEMS_SUCCESSFUL);
 
-  rtems_task_start(
+  status = rtems_task_start(
 cons->task,
 _Console_simple_task_Task,
 (rtems_task_argument) cons
   );
+  _Assert_Unused_variable_equals(status, RTEMS_SUCCESSFUL);
 }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 3/3] rtems-debugger-target.c: Fix Coverity Dereference before null check

2021-02-12 Thread Ryan Long
Fixes CID #1468682 where target is dereferenced before it has been
checked as to whether it is null or not in the
rtems_debugger_target_swbreak_control function.

Fix file rtems-debugger-target.c
---
 cpukit/libdebugger/rtems-debugger-target.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/cpukit/libdebugger/rtems-debugger-target.c 
b/cpukit/libdebugger/rtems-debugger-target.c
index e495170..bf75797 100644
--- a/cpukit/libdebugger/rtems-debugger-target.c
+++ b/cpukit/libdebugger/rtems-debugger-target.c
@@ -171,17 +171,19 @@ int
 rtems_debugger_target_swbreak_control(bool insert, DB_UINT addr, DB_UINT kind)
 {
   rtems_debugger_target* target = rtems_debugger->target;
-  rtems_debugger_target_swbreak* swbreaks = target->swbreaks.block;
+  rtems_debugger_target_swbreak* swbreaks;
   size_t swbreak_size;
   uint8_t*   loc = (void*) addr;
   size_t i;
   intr;
 
-  if (target == NULL || swbreaks == NULL || kind != target->breakpoint_size) {
+  if (target == NULL || target->swbreaks.block == NULL ||
+  kind != target->breakpoint_size) {
 errno = EIO;
 return -1;
   }
 
+  swbreaks = target->swbreaks.block;
   swbreak_size =
 sizeof(rtems_debugger_target_swbreak) + target->breakpoint_size;
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 0/3] Fix for Coverity issues

2021-02-12 Thread Ryan Long
Hi,

Here are the patches with the suggested changes. The macros are now
_Assert_Unused_variable equals and _Assert_Unused_variable_unequal. I
made the corresponding change in consolesimpletask.c. In
rtems-debugger-target.c, I moved the declaration of the swbreaks
variable back to the top of the function and assigned its value where I
had declared and initialized it in the first version of this patch.

Thanks,
Ryan

Ryan Long (3):
  assert.h: Add macros to assert status and use it
  consolesimpletask.c: Fix Coverity Unchecked return value
  rtems-debugger-target.c: Fix Coverity Dereference before null check

 cpukit/include/rtems/score/assert.h| 30 ++
 cpukit/libcsupport/src/consolesimpletask.c |  7 +--
 cpukit/libdebugger/rtems-debugger-target.c |  6 --
 3 files changed, 39 insertions(+), 4 deletions(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 1/3] assert.h: Add macros to assert status and use it

2021-02-12 Thread Ryan Long
These macros are to be used to check the status from calls that are flagged by
Coverity as 'Unchecked return value'.

Fix file assert.h
---
 cpukit/include/rtems/score/assert.h | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/cpukit/include/rtems/score/assert.h 
b/cpukit/include/rtems/score/assert.h
index cc32448..6bdb01e 100644
--- a/cpukit/include/rtems/score/assert.h
+++ b/cpukit/include/rtems/score/assert.h
@@ -99,6 +99,36 @@ extern "C" {
 #endif
 
 /**
+ * @brief Assert if unused return value is equal.
+ *
+ * Assert whether @a _var and @a _val are equal and ensure @a _var is
+ * marked as used when not building for debug.
+ *
+ * @param _var The return value to be checked.
+ * @param _val Indicates what @a _var is supposed to be.
+ */
+#define _Assert_Unused_variable_equals(_var,_val) \
+do { \
+  _Assert((_var) == (_val)); \
+  (void) (_var); \
+} while (0)
+
+/**
+ * @brief Assert if unused return value is not equal.
+ *
+ * Assert whether @a _var and @a _val are not equal and ensure @a _var
+ * is marked as used when not building for debug.
+ *
+ * @param _var The return value to be checked.
+ * @param _val Indicates what @a _var is not supposed to be.
+ */
+#define _Assert_Unused_variable_unequal(_var,_val) \
+ do { \
+  _Assert((_var) != (_val)); \
+   (void) (_var); \
+} while (0)
+
+/**
  * @brief Returns true if thread dispatching is allowed.
  *
  * Thread dispatching can be repressed via _Thread_Disable_dispatch() or
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 3/5] grtc.c: Fix Dereference before null check (CID #1399840)

2021-02-18 Thread Ryan Long
CID 1399840: Dereference before null check in grtc_ioctl().

Closes #4252
---
 bsps/shared/grlib/tmtc/grtc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bsps/shared/grlib/tmtc/grtc.c b/bsps/shared/grlib/tmtc/grtc.c
index 44e9685..e9acea4 100644
--- a/bsps/shared/grlib/tmtc/grtc.c
+++ b/bsps/shared/grlib/tmtc/grtc.c
@@ -1532,7 +1532,7 @@ static rtems_device_driver 
grtc_ioctl(rtems_device_major_number major, rtems_dev
struct grtc_priv *pDev;
struct drvmgr_dev *dev;
rtems_libio_ioctl_args_t *ioarg = (rtems_libio_ioctl_args_t *)arg;
-   unsigned int *data = ioarg->buffer;
+   unsigned int *data;
int status,frm_len,i,ret;
struct grtc_ioc_buf_params *buf_arg;
struct grtc_ioc_config *cfg;
@@ -1556,6 +1556,8 @@ static rtems_device_driver 
grtc_ioctl(rtems_device_major_number major, rtems_dev
if (!ioarg)
return RTEMS_INVALID_NAME;
 
+data = ioarg->buffer;
+
ioarg->ioctl_return = 0;
switch(ioarg->command) {
case GRTC_IOC_START:
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 4/5] grspw_pkt.c: Fix Dereference before null check (CID #1399846)

2021-02-18 Thread Ryan Long
CID 1399846: Dereference before null check in grspw_addr_ctrl().

Closes #4253
---
 bsps/shared/grlib/spw/grspw_pkt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bsps/shared/grlib/spw/grspw_pkt.c 
b/bsps/shared/grlib/spw/grspw_pkt.c
index 2cc4e886..ca8767e 100644
--- a/bsps/shared/grlib/spw/grspw_pkt.c
+++ b/bsps/shared/grlib/spw/grspw_pkt.c
@@ -655,7 +655,7 @@ void grspw_hw_support(void *d, struct grspw_hw_sup *hw)
 void grspw_addr_ctrl(void *d, struct grspw_addr_config *cfg)
 {
struct grspw_priv *priv = d;
-   struct grspw_regs *regs = priv->regs;
+   struct grspw_regs *regs;
unsigned int ctrl, nodeaddr;
SPIN_IRQFLAGS(irqflags);
int i;
@@ -663,6 +663,8 @@ void grspw_addr_ctrl(void *d, struct grspw_addr_config *cfg)
if (!priv || !cfg)
return;
 
+regs = priv->regs;
+
SPIN_LOCK_IRQ(>devlock, irqflags);
 
if (cfg->promiscuous != -1) {
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 5/5] shell.c: Fix Dereference before null check (CID #1467420)

2021-02-18 Thread Ryan Long
CID 1467420: Dereference before null check in rtems_shell_line_editor().

Closes #4254
---
 cpukit/libmisc/shell/shell.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c
index 3c357a1..1e5962b 100644
--- a/cpukit/libmisc/shell/shell.c
+++ b/cpukit/libmisc/shell/shell.c
@@ -320,7 +320,10 @@ static int rtems_shell_line_editor(
   int  cmd = -1;
   int  inserting = 1;
   int  in_fileno = fileno(in);
-  int  out_fileno = fileno(out);
+  int  out_fileno;
+
+  _Assert(out != NULL);
+  out_fileno = fileno(out);
 
   /*
* Only this task can use this file descriptor because calling
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 0/5] Fix Dereference before null check errors

2021-02-18 Thread Ryan Long
Hi,

I fixed these "Dereference before null check errors in Coverity. I
didn't have to add anything to most of these files. I mainly just had to
move the assignment of the pointers being flagged to after their
corresponding check. In shell.c, I added an _Assert() to ensure that the
pointer wasn't null before being passed to fileno().

Thanks,
Ryan

Ryan Long (5):
  b1553brm.c: Fix Dereference before null check (CID #1399829)
  b1553rt.c: Fix Deference before null check (CID #1399830)
  grtc.c: Fix Dereference before null check (CID #1399840)
  grspw_pkt.c: Fix Dereference before null check (CID #1399846)
  shell.c: Fix Dereference before null check (CID #1467420)

 bsps/shared/grlib/1553/b1553brm.c | 7 +--
 bsps/shared/grlib/1553/b1553rt.c  | 4 +++-
 bsps/shared/grlib/spw/grspw_pkt.c | 4 +++-
 bsps/shared/grlib/tmtc/grtc.c | 4 +++-
 cpukit/libmisc/shell/shell.c  | 5 -
 5 files changed, 18 insertions(+), 6 deletions(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 1/5] b1553brm.c: Fix Dereference before null check (CID #1399829)

2021-02-18 Thread Ryan Long
CID 1399829: Dereference before null check in brm_control().

Closes #4250
---
 bsps/shared/grlib/1553/b1553brm.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/bsps/shared/grlib/1553/b1553brm.c 
b/bsps/shared/grlib/1553/b1553brm.c
index 57ef701..694f585 100644
--- a/bsps/shared/grlib/1553/b1553brm.c
+++ b/bsps/shared/grlib/1553/b1553brm.c
@@ -994,8 +994,8 @@ static rtems_device_driver 
brm_control(rtems_device_major_number major, rtems_de
unsigned int i=0;
unsigned short ctrl, oper, cw1, cw2;
rtems_libio_ioctl_args_t *ioarg = (rtems_libio_ioctl_args_t *) arg;
-   unsigned int *data = ioarg->buffer;
-   struct bc_msg *cmd_list = (struct bc_msg *) ioarg->buffer;
+   unsigned int *data;
+   struct bc_msg *cmd_list;
brm_priv *brm;
struct drvmgr_dev *dev;
rtems_device_driver ret;
@@ -1013,6 +1013,9 @@ static rtems_device_driver 
brm_control(rtems_device_major_number major, rtems_de
return RTEMS_INVALID_NAME;
}
 
+data = ioarg->buffer;
+cmd_list = (struct bc_msg *) ioarg->buffer;
+
ioarg->ioctl_return = 0;
switch (ioarg->command) {
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/5] b1553rt.c: Fix Deference before null check (CID #1399830)

2021-02-18 Thread Ryan Long
CID 1399830: Dereference before null check in rt_control().

Closes #4251
---
 bsps/shared/grlib/1553/b1553rt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bsps/shared/grlib/1553/b1553rt.c b/bsps/shared/grlib/1553/b1553rt.c
index d7257e4..df72ada 100644
--- a/bsps/shared/grlib/1553/b1553rt.c
+++ b/bsps/shared/grlib/1553/b1553rt.c
@@ -619,7 +619,7 @@ static rtems_device_driver 
rt_write(rtems_device_major_number major, rtems_devic
 static rtems_device_driver rt_control(rtems_device_major_number major, 
rtems_device_minor_number minor, void *arg)
 {
 rtems_libio_ioctl_args_t *ioarg = (rtems_libio_ioctl_args_t *) arg;
-unsigned int *data = ioarg->buffer;
+unsigned int *data;
 
 rt_priv *rt;
 struct drvmgr_dev *dev;
@@ -636,6 +636,8 @@ static rtems_device_driver 
rt_control(rtems_device_major_number major, rtems_dev
 return RTEMS_INVALID_NAME;
 }
 
+data = ioarg->buffer;
+
 ioarg->ioctl_return = 0;
 switch (ioarg->command) {
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 4/4] rtems-debugger-target.c: Fix Coverity Dereference before null check

2021-02-11 Thread Ryan Long
Fixes CID #1468682 where target is dereferenced before it has been
checked as to whether it is null or not in the
rtems_debugger_target_swbreak_control function.
---
 cpukit/libdebugger/rtems-debugger-target.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/cpukit/libdebugger/rtems-debugger-target.c 
b/cpukit/libdebugger/rtems-debugger-target.c
index e495170..3726a6c 100644
--- a/cpukit/libdebugger/rtems-debugger-target.c
+++ b/cpukit/libdebugger/rtems-debugger-target.c
@@ -171,17 +171,18 @@ int
 rtems_debugger_target_swbreak_control(bool insert, DB_UINT addr, DB_UINT kind)
 {
   rtems_debugger_target* target = rtems_debugger->target;
-  rtems_debugger_target_swbreak* swbreaks = target->swbreaks.block;
   size_t swbreak_size;
   uint8_t*   loc = (void*) addr;
   size_t i;
   intr;
 
-  if (target == NULL || swbreaks == NULL || kind != target->breakpoint_size) {
+  if (target == NULL || target->swbreaks.block == NULL ||
+  kind != target->breakpoint_size) {
 errno = EIO;
 return -1;
   }
 
+  rtems_debugger_target_swbreak* swbreaks = target->swbreaks.block;
   swbreak_size =
 sizeof(rtems_debugger_target_swbreak) + target->breakpoint_size;
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 3/4] rtems-debugger-threads.c: Fix Coverity Dereference before null check

2021-02-11 Thread Ryan Long
Fixes CID #1468681, 1468690, and 1468694 by checking if threads is null in
the rtems_debugger_thread_find_index, rtems_debugger_thread_system_resume,
and rtems_debugger_thread_continue_all functions.
---
 cpukit/libdebugger/rtems-debugger-threads.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/cpukit/libdebugger/rtems-debugger-threads.c 
b/cpukit/libdebugger/rtems-debugger-threads.c
index 84a9faa..5b96e5f 100644
--- a/cpukit/libdebugger/rtems-debugger-threads.c
+++ b/cpukit/libdebugger/rtems-debugger-threads.c
@@ -148,9 +148,9 @@ int
 rtems_debugger_thread_find_index(rtems_id id)
 {
   rtems_debugger_threads* threads = rtems_debugger->threads;
-  rtems_debugger_thread*  current = rtems_debugger_thread_current(threads);
   int r = -1;
   if (threads != NULL) {
+rtems_debugger_thread* current = rtems_debugger_thread_current(threads);
 size_t i;
 for (i = 0; i < threads->current.level; ++i) {
   if (id == 0 || current[i].id == id) {
@@ -347,8 +347,11 @@ rtems_debugger_thread_system_resume(bool detaching)
   rtems_debugger_threads* threads = rtems_debugger->threads;
   rtems_debugger_thread*  current;
   int r = 0;
+  if (threads == NULL) {
+return r;
+  }
   current = rtems_debugger_thread_current(threads);
-  if (threads != NULL && current != NULL) {
+  if (current != NULL) {
 size_t i;
 if (rtems_debugger_verbose())
   rtems_debugger_printf("rtems-db: sys:: resuming\n");
@@ -430,8 +433,13 @@ rtems_debugger_thread_continue_all(void)
   rtems_debugger_threads* threads = rtems_debugger->threads;
   rtems_debugger_thread*  current;
   int r = 0;
+  if (threads == NULL) {
+r = -1;
+errno = EIO;
+return r;
+  }
   current = rtems_debugger_thread_current(threads);
-  if (threads != NULL && current != NULL) {
+  if (current != NULL) {
 size_t i;
 for (i = 0; i < threads->current.level; ++i) {
   rtems_debugger_thread* thread = [i];
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/4] consolesimpletask.c: Fix Coverity Unchecked return value

2021-02-11 Thread Ryan Long
Fixes CID #1437625 and #1472765 where the return value of rtems_task_create and
rtems_task_start is discarded.
---
 cpukit/libcsupport/src/consolesimpletask.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/cpukit/libcsupport/src/consolesimpletask.c 
b/cpukit/libcsupport/src/consolesimpletask.c
index 82ea2a5..927085b 100644
--- a/cpukit/libcsupport/src/consolesimpletask.c
+++ b/cpukit/libcsupport/src/consolesimpletask.c
@@ -217,6 +217,7 @@ static const char _Console_simple_task_Name[] = "console";
 void _Console_simple_task_Initialize( void )
 {
   Console_simple_task_Control *cons;
+  rtems_status_code status;
 
   cons = &_Console_simple_task_Instance;
 
@@ -233,7 +234,7 @@ void _Console_simple_task_Initialize( void )
 
   IMFS_add_node( "/dev", >Node, NULL );
 
-  rtems_task_create(
+  status = rtems_task_create(
 rtems_build_name('C', 'O', 'N', 'S'),
 RTEMS_MAXIMUM_PRIORITY - 1,
 RTEMS_MINIMUM_STACK_SIZE,
@@ -241,10 +242,12 @@ void _Console_simple_task_Initialize( void )
 RTEMS_DEFAULT_MODES,
 >task
   );
+  _Assert_Unused_return_value_equal(status, RTEMS_SUCCESSFUL);
 
-  rtems_task_start(
+  status = rtems_task_start(
 cons->task,
 _Console_simple_task_Task,
 (rtems_task_argument) cons
   );
+  _Assert_Unused_return_value_equal(status, RTEMS_SUCCESSFUL);
 }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 1/4] assert.h: Add macros to assert status and use it

2021-02-11 Thread Ryan Long
These macros are to be used to check the status from calls that are flagged by
Coverity as 'Unchecked return value'.
---
 cpukit/include/rtems/score/assert.h | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/cpukit/include/rtems/score/assert.h 
b/cpukit/include/rtems/score/assert.h
index cc32448..7efaae4 100644
--- a/cpukit/include/rtems/score/assert.h
+++ b/cpukit/include/rtems/score/assert.h
@@ -99,6 +99,36 @@ extern "C" {
 #endif
 
 /**
+ * @brief Assert if unused return value is equal.
+ *
+ * Assert whether @a _status and @a _value are equal and ensure @a _status is
+ * marked as used when not building for debug.
+ *
+ * @param _status The return value to be checked.
+ * @param _value Indicates what @a _status is supposed to be.
+ */
+#define _Assert_Unused_return_value_equal(_status,_value) \
+do { \
+  _Assert((_status) == (_value)); \
+  (void) (_status); \
+} while (0)
+
+/**
+ * @brief Assert if unused return value is not equal.
+ *
+ * Assert whether @a _status and @a _value are not equal and ensure @a _status
+ * is marked as used when not building for debug.
+ *
+ * @param _status The return value to be checked.
+ * @param _value Indicates what @a _status is not supposed to be.
+ */
+#define _Assert_Unused_return_value_not_equal(_status,_value) \
+ do { \
+  _Assert((_status) != (_value)); \
+   (void) (_status); \
+} while (0)
+
+/**
  * @brief Returns true if thread dispatching is allowed.
  *
  * Thread dispatching can be repressed via _Thread_Disable_dispatch() or
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 0/4] Fix for Coverity issues

2021-02-11 Thread Ryan Long
Hi,

I created some macros to assert the status returned from function calls,
and use that status based on Gedare and Joel's suggestions. I
implemented the macros in consolesimpletask.c. I fixed some issues for
the 'Dereference before null check' in a couple of files. This mainly
entailed moving around the dereferencing of values.

Thanks,
Ryan

Ryan Long (4):
  assert.h: Add macros to assert status and use it
  consolesimpletask.c: Fix Coverity Unchecked return value
  rtems-debugger-threads.c: Fix Coverity Dereference before null check
  rtems-debugger-target.c: Fix Coverity Dereference before null check

 cpukit/include/rtems/score/assert.h | 30 +
 cpukit/libcsupport/src/consolesimpletask.c  |  7 +--
 cpukit/libdebugger/rtems-debugger-target.c  |  5 +++--
 cpukit/libdebugger/rtems-debugger-threads.c | 14 +++---
 4 files changed, 49 insertions(+), 7 deletions(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2] psx13: Reworked and relicensed

2021-04-22 Thread Ryan Long
Changed the way the tests were structured, added rtems_test_assert()'s,
updated psx13.scn and the license.
---
 testsuites/psxtests/psx13/main.c|  37 +-
 testsuites/psxtests/psx13/psx13.scn |  21 +-
 testsuites/psxtests/psx13/test.c| 852 
 3 files changed, 328 insertions(+), 582 deletions(-)

diff --git a/testsuites/psxtests/psx13/main.c b/testsuites/psxtests/psx13/main.c
index 20788b3..f9e7907 100644
--- a/testsuites/psxtests/psx13/main.c
+++ b/testsuites/psxtests/psx13/main.c
@@ -1,14 +1,37 @@
-/*
- *  Simple test program -- simplified version of sample test hello.
+/*  SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ *  @file
  *
- *  COPYRIGHT (c) 1989-2009.
- *  On-Line Applications Research Corporation (OAR).
+ *  @brief Simple test program -- simplified version of sample test hello.
  *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
  */
 
+/*
+ *  COPYRIGHT (c) 1989-2009, 2021.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/testsuites/psxtests/psx13/psx13.scn 
b/testsuites/psxtests/psx13/psx13.scn
index 428a931..efa79c9 100644
--- a/testsuites/psxtests/psx13/psx13.scn
+++ b/testsuites/psxtests/psx13/psx13.scn
@@ -1,16 +1,7 @@
-*** POSIX TEST 13 ***
+*** BEGIN OF TEST PSX 13 ***
+*** TEST VERSION: 6.0.0.75f80242186af2dde0c5bc7272a119e3b78d7ba0
+*** TEST STATE: EXPECTED_PASS
+*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API
+*** TEST TOOLS: 10.2.1 20210309 (RTEMS 6, RSB 
5e449fb5c2cb6812a238f9f9764fd339cbbf05c2, Newlib d10d0d9)
 
-Files initialized successfully.
-Testing device_lseek()... Failed!!!
-Testing dup() Failed!!!
-Testing dup2()... Success.
-Testing fdatasync().. Success.
-Testing umask().. Success.
-Testing utime().. Success.
-Testing utimes().. Success.
-Testing fsync().. Success.
-Testing pathconf()... Success.
-Testing fpathconf().. Success.
-Testing sync().. 
-
-*** END OF TEST PSX13 ***
+*** END OF TEST PSX 13 ***
diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c
index 79b24c2..a82242b 100644
--- a/testsuites/psxtests/psx13/test.c
+++ b/testsuites/psxtests/psx13/test.c
@@ -1,26 +1,49 @@
-/*
- *  Psx13
- *  Chris Bond (working under Jennifer's account)
+/*  SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ *  @file
  *
- *  This test exercises the following routines:
+ *  @brief This tests various file system functions.
  *
- * device_lseek - test implemented
- * dup  - test implemented
- * dup2 - test implemented
- * fdatasync- test implemented
- * fsync- test implemented
- * pathconf - test implemented
- * fpathconf- test implemented
- * umask- test implemented
- * utime- test implemented
- * utimes   - test implemented
+ *  This test exercises the following routines:
  *
- *  COPYRIGHT (c) 1989-2009.
+ * - lseek()
+ * - dup()
+ * - dup2()
+ * - fdatasync()
+ * - fsync()
+ * - pathconf()
+ * - fpathconf()
+ * - umask()
+ * - utime()
+ * - utimes()
+ * - sync()
+ */
+
+/*
+ *  COPYRIGHT (c) 1989-2009, 2021.
  *  On-Line Applications Research Corporation (OAR).
  *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted 

[PATCH v1 3/3] rld-dwarf.cpp: Initialize member variables

2021-08-24 Thread Ryan Long
Initialize member variables not listed.

CID 1503019: Uninitialized scalar field.

Closes #4500
---
 rtemstoolkit/rld-dwarf.cpp | 12 
 1 file changed, 12 insertions(+)

diff --git a/rtemstoolkit/rld-dwarf.cpp b/rtemstoolkit/rld-dwarf.cpp
index 1eae50c..2d6f306 100644
--- a/rtemstoolkit/rld-dwarf.cpp
+++ b/rtemstoolkit/rld-dwarf.cpp
@@ -679,12 +679,18 @@ namespace rld
 machine_code_ (false),
 external_ (false),
 declaration_ (false),
+prototyped_ (false),
 inline_ (DW_INL_not_inlined),
 entry_pc_ (0),
 has_entry_pc_ (false),
 pc_low_ (0),
 pc_high_ (0),
 ranges_ (debug),
+name_ (),
+linkage_name_ (),
+decl_file_ (),
+decl_line_ (0),
+call_file_ (),
 call_line_ (0)
 {
   dwarf_bool db;
@@ -819,6 +825,7 @@ namespace rld
 machine_code_ (orig.machine_code_),
 external_ (orig.external_),
 declaration_ (orig.declaration_),
+prototyped_ (orig.prototyped_),
 inline_ (orig.inline_),
 entry_pc_ (orig.entry_pc_),
 has_entry_pc_ (orig.has_entry_pc_),
@@ -827,6 +834,8 @@ namespace rld
 ranges_ (orig.ranges_),
 name_ (orig.name_),
 linkage_name_ (orig.linkage_name_),
+decl_file_ (orig.decl_file_),
+decl_line_ (orig.decl_line_),
 call_file_ (orig.call_file_),
 call_line_ (orig.call_line_)
 {
@@ -986,7 +995,10 @@ namespace rld
 ranges_ = rhs.ranges_;
 name_ = rhs.name_;
 linkage_name_ = rhs.linkage_name_;
+decl_file_ = rhs.decl_file_;
+decl_line_ = rhs.decl_line_;
 call_file_ = rhs.call_file_;
+call_line_ = rhs.call_line_;
   }
   return *this;
 }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 0/3] Uninitialized scalar field Coverity issues

2021-08-24 Thread Ryan Long
Hi,

To fix these issues I just needed to add the missing member variables from the
initialization lists.

Thanks,
Ryan

Ryan Long (3):
  rtems-exeinfo.cpp: Initialize byteorder
  GcovData.cc: Initialize gcnoPreamble
  rld-dwarf.cpp: Initialize member variables

 linkers/rtems-exeinfo.cpp  |  3 ++-
 rtemstoolkit/rld-dwarf.cpp | 12 
 tester/covoar/GcovData.cc  |  1 +
 3 files changed, 15 insertions(+), 1 deletion(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 1/3] rtems-exeinfo.cpp: Initialize byteorder

2021-08-24 Thread Ryan Long
CID 1471637: Uninitialized scalar field

Closes #4499
---
 linkers/rtems-exeinfo.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/linkers/rtems-exeinfo.cpp b/linkers/rtems-exeinfo.cpp
index caae168..e54f9b2 100644
--- a/linkers/rtems-exeinfo.cpp
+++ b/linkers/rtems-exeinfo.cpp
@@ -210,7 +210,8 @@ namespace rld
 
 section::section (const section& orig)
   : sec (orig.sec),
-data (orig.data)
+data (orig.data),
+byteorder (orig.byteorder)
 {
 }
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 2/3] GcovData.cc: Initialize gcnoPreamble

2021-08-24 Thread Ryan Long
CID 1506206: Uninitialized scalar field

Closes #4487
---
 tester/covoar/GcovData.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tester/covoar/GcovData.cc b/tester/covoar/GcovData.cc
index 02e7489..723e9af 100644
--- a/tester/covoar/GcovData.cc
+++ b/tester/covoar/GcovData.cc
@@ -21,6 +21,7 @@ namespace Gcov {
 
   GcovData::GcovData( Coverage::DesiredSymbols& symbolsToAnalyze ):
 numberOfFunctions( 0 ),
+gcnoPreamble(),
 symbolsToAnalyze_m( symbolsToAnalyze )
   {
   }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] GcovData.cc: Remove ampersands where not needed

2021-08-23 Thread Ryan Long
Removed some ampersands that were left in on accident.
---
 tester/covoar/GcovData.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tester/covoar/GcovData.cc b/tester/covoar/GcovData.cc
index 44928a9..59412a6 100644
--- a/tester/covoar/GcovData.cc
+++ b/tester/covoar/GcovData.cc
@@ -404,7 +404,7 @@ namespace Gcov {
 
 // Read the gcov preamble and make sure it is the right length and has the
 // magic number
-gcovFile.read( (char *) , sizeof( gcov_preamble ) );
+gcovFile.read( (char *) preamble, sizeof( gcov_preamble ) );
 if ( gcovFile.gcount() != sizeof( gcov_preamble ) ) {
   std::cerr << "Error while reading file preamble" << std::endl;
   return -1;
@@ -429,7 +429,7 @@ namespace Gcov {
 char buffer[512];
 char intBuffer[16384];
 
-gcovFile.read( (char *) , 8 );
+gcovFile.read( (char *) intBuffer, 8 );
 if ( gcovFile.gcount() != 8 ) {
   std::cerr << "ERROR: Unable to read Function ID & checksum" << std::endl;
   return false;
@@ -443,7 +443,7 @@ namespace Gcov {
 function->setFunctionName( buffer, symbolsToAnalyze_m );
 header.length -= readString( buffer, gcovFile );
 function->setFileName( buffer );
-gcovFile.read( (char*) , 4 * header.length );
+gcovFile.read( (char*) intBuffer, 4 * header.length );
 if (gcovFile.gcount() != 4 * header.length ) {
   std::cerr << "ERROR: Unable to read Function starting line number"
 << std::endl;
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] aarch64: Add tests that are failing intermittently

2021-08-19 Thread Ryan Long
- Change status of all spintrcritical tests to indeterminate, expanded upon
  comments.
- Add indeterminate tests to xilinx-versal
---
 spec/build/bsps/aarch64/a53/tsta53.yml| 40 ++---
 spec/build/bsps/aarch64/xilinx-versal/tstqemu.yml | 54 ++-
 spec/build/bsps/aarch64/xilinx-zynqmp/tstqemu.yml | 40 ++---
 3 files changed, 120 insertions(+), 14 deletions(-)

diff --git a/spec/build/bsps/aarch64/a53/tsta53.yml 
b/spec/build/bsps/aarch64/a53/tsta53.yml
index f263557..6e8f348 100644
--- a/spec/build/bsps/aarch64/a53/tsta53.yml
+++ b/spec/build/bsps/aarch64/a53/tsta53.yml
@@ -1,20 +1,26 @@
 SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
 actions:
 - set-test-state:
-# expected to fail, don't compile these
+# This test fails when ran through rtems-tester because it does not
+# produce any output.
 minimum: exclude
 
-# don't compile due to toolchain issues
+# These tests do not compile due to an issue with the GNU Assembler.
+# The issue has been filed(https://devel.rtems.org/ticket/4218).
+# Once the issue has been fixed, these tests will be turned back on.
 spconfig01: exclude
 spmisc01: exclude
 
-# tests that are passing intermittently
+# These tests may or may not fail, however, they do pass on real hardware.
+# It seems to be an issue with QEMU.
 spcpucounter01: indeterminate
+sptimecounter01: indeterminate
 rtmonuse: indeterminate
-sp68: indeterminate
 sp04: indeterminate
 sp20: indeterminate
+sp68: indeterminate
 sp69: indeterminate
+sp71: indeterminate
 rtmonusxtimes01: indeterminate
 spedfsched02: indeterminate
 spedfsched04: indeterminate
@@ -24,12 +30,34 @@ actions:
 sptimecounter04: indeterminate
 ttest02: indeterminate
 
-# tests that pass nominally, but fail under Qemu when the host is under
-# heavy load
+# These tests may or may not fail, however, they do pass on real hardware.
+# It seems to be an issue with Qemu, and that this only occurs when the
+# host machine is under a heavy load.
 psx12: indeterminate
+spintrcritical01: indeterminate
+spintrcritical02: indeterminate
 spintrcritical03: indeterminate
 spintrcritical04: indeterminate
 spintrcritical05: indeterminate
+spintrcritical06: indeterminate
+spintrcritical07: indeterminate
+spintrcritical08: indeterminate
+spintrcritical09: indeterminate
+spintrcritical10: indeterminate
+spintrcritical11: indeterminate
+spintrcritical12: indeterminate
+spintrcritical13: indeterminate
+spintrcritical14: indeterminate
+spintrcritical15: indeterminate
+spintrcritical16: indeterminate
+spintrcritical17: indeterminate
+spintrcritical18: indeterminate
+spintrcritical19: indeterminate
+spintrcritical20: indeterminate
+spintrcritical21: indeterminate
+spintrcritical22: indeterminate
+spintrcritical23: indeterminate
+spintrcritical24: indeterminate
 build-type: option
 copyrights:
 - Copyright (C) 2020 On-Line Applications Research (OAR)
diff --git a/spec/build/bsps/aarch64/xilinx-versal/tstqemu.yml 
b/spec/build/bsps/aarch64/xilinx-versal/tstqemu.yml
index 43f6b2e..884effc 100644
--- a/spec/build/bsps/aarch64/xilinx-versal/tstqemu.yml
+++ b/spec/build/bsps/aarch64/xilinx-versal/tstqemu.yml
@@ -1,13 +1,63 @@
 SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
 actions:
 - set-test-state:
-# expected to fail
+# This test fails when ran through rtems-tester because it does not
+# produce any output.
 minimum: exclude
 
-# don't compile due to toolchain issues, see RTEMS issue #4218
+# These tests do not compile due to an issue with the GNU Assembler.
+# The issue has been filed(https://devel.rtems.org/ticket/4218).
+# Once the issue has been fixed, these tests will be turned back on.
 spconfig01: exclude
 spmisc01: exclude
 
+# These tests may or may not fail, however, they do pass on real hardware.
+# It seems to be an issue with Qemu.
+spcpucounter01: indeterminate
+sptimecounter01: indeterminate
+rtmonuse: indeterminate
+sp04: indeterminate
+sp20: indeterminate
+sp68: indeterminate
+sp69: indeterminate
+sp71: indeterminate
+rtmonusxtimes01: indeterminate
+spedfsched02: indeterminate
+spedfsched04: indeterminate
+psxtimes01: indeterminate
+sprmsched01: indeterminate
+sptimecounter02: indeterminate
+sptimecounter04: indeterminate
+ttest02: indeterminate
+
+# These tests may or may not fail, however, they do pass on real hardware.
+# It seems to be an issue with Qemu, and that this only occurs when the
+# host machine is under a heavy load.
+psx12: indeterminate
+spintrcritical01: indeterminate
+spintrcritical02: indeterminate
+spintrcritical03: indeterminate
+spintrcritical04: indeterminate
+spintrcritical05: indeterminate

[PATCH] TraceWriterQEMU.cc: Change strncpy to memcpy

2021-08-19 Thread Ryan Long
CID 1506207: Buffer not null terminated

Closes #4491
---
 tester/covoar/TraceWriterQEMU.cc | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tester/covoar/TraceWriterQEMU.cc b/tester/covoar/TraceWriterQEMU.cc
index c417745..be9b6e1 100644
--- a/tester/covoar/TraceWriterQEMU.cc
+++ b/tester/covoar/TraceWriterQEMU.cc
@@ -106,7 +106,10 @@ namespace Trace {
 //
 //  Write the Header to the file
 //
-strncpy( header.magic, QEMU_TRACE_MAGIC, sizeof(header.magic) );
+// The header.magic field is actually 12 bytes, but QEMU_TRACE_MAGIC is
+// 13 bytes including the NULL.
+const char qemu_trace_magic[13] = QEMU_TRACE_MAGIC;
+memcpy( header.magic, qemu_trace_magic, sizeof(header.magic) );
 header.version = QEMU_TRACE_VERSION;
 header.kind= QEMU_TRACE_KIND_RAW;  // XXX ??
 header.sizeof_target_pc = 32;
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


RE: [PATCH v1 00/10] Convert and reformat rtems-tools pt. 1

2021-09-03 Thread Ryan Long
I haven't been building these with clang, so I'll make sure to start doing 
that. I've got a Macbook, so I can test it on there as well.

-Original Message-
From: Chris Johns  
Sent: Thursday, September 2, 2021 11:59 PM
To: Ryan Long ; devel@rtems.org
Subject: Re: [PATCH v1 00/10] Convert and reformat rtems-tools pt. 1

On 3/9/21 5:24 am, Ryan Long wrote:
> For this and the following series of patches I followed this series of 
> steps.
> 
> 1. Convert a file from the C way of doing things to C++ 2. Go through 
> all the files that had to do with the converted file and make the 
> formatting consistent.

Looks good and thanks for taking this on.

Have you built this with clang on FreeBSD? I only ask because the minor fix I 
pushed where clang complained about the `std::ostream::tellp()` return value 
being compared to `long int` 

https://lists.rtems.org/pipermail/build/2021-September/028853.html

I suspect if this change build on FreeBSD it will also build on MacOS. Do you 
have access to a MacOS machine?

There is a new piece of code around `gcount()` and this is the reason for my 
question.

Chris



___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH RSB] rtems-gcc-10-newlib-head.cfg: Add newlib patch

2021-09-03 Thread Ryan Long
Adds patch to add the -DPREFER_SIZE_OVER_SPEED flag to aarch64 tool
builds with newlib.
---
 rtems/config/tools/rtems-gcc-10-newlib-head.cfg | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg 
b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
index 69c4fb5..3594d1c 100644
--- a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
+++ b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
@@ -13,6 +13,9 @@
 %patch add gcc -p1 
https://devel.rtems.org/raw-attachment/ticket/4215/0001-nios2-Remove-custom-instruction-warnings.patch
 %hash sha512 0001-nios2-Remove-custom-instruction-warnings.patch 
afd8a5e6bdcc5b75d5fbbf558bdf56ccac400521a6eec9d88cc95f6be67c481f2dbf8faa0f6ddc1e4ac7c56a84938714d80e46e9cf80ec4b8fcd739986449881
 
+%patch add newlib -p1 
https://devel.rtems.org/raw-attachment/ticket/4510/0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch
+%hash sha512 0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch 
ad183b6c9a168d1d751505e64873f117c11fb059819d341c5d715619985b285c324ef27c1177c6300088df7bbe3aebd7fa034034c3892f2bf6ec57324c9b1e2a
+
 %define newlib_version 4f81149
 %define newlib_external 1
 %define newlib_expand_name sourceware-mirror-newlib-cygwin-%{newlib_version}
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] TraceWriterQEMU.cc: Initialize header._pad

2021-09-01 Thread Ryan Long
CID 1506204: Uninitialized scalar variable

Closes #4488
---
 tester/covoar/TraceWriterQEMU.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tester/covoar/TraceWriterQEMU.cc b/tester/covoar/TraceWriterQEMU.cc
index c417745..cc849b6 100644
--- a/tester/covoar/TraceWriterQEMU.cc
+++ b/tester/covoar/TraceWriterQEMU.cc
@@ -113,6 +113,7 @@ namespace Trace {
 header.big_endian = false;
 header.machine[0] = 0; // XXX ??
 header.machine[1] = 0; // XXX ??
+header._pad = 0;
 status = ::fwrite( , sizeof(trace_header), 1, traceFile );
 if (status != 1) {
   std::cerr << "Unable to write header to " << file << std::endl;
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v1 0/4] Initialize pointer fields

2021-09-01 Thread Ryan Long
Hi,

These patches will get rid of the "Uninitialized pointer field" Coverity
issues. I noticed that some other member variables were not initialized
while doing this, so I initialized them as well.

Thanks,
Ryan

Ryan Long (4):
  DesiredSymbols.h: Initialize symbolInfo
  GcovFunctionData.cc: Initialize member variables
  record-filter-zlib.cc: Initialize stream_'s fields
  ObjdumpProcessor.h: Remove inputBuffer_m

 tester/covoar/DesiredSymbols.h |  1 +
 tester/covoar/GcovFunctionData.cc  | 10 +++---
 tester/covoar/ObjdumpProcessor.h   |  5 -
 trace/record/record-filter-zlib.cc | 13 +
 4 files changed, 21 insertions(+), 8 deletions(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v1 3/4] record-filter-zlib.cc: Initialize stream_'s fields

2021-09-01 Thread Ryan Long
CID 1503020: Uninitialized pointer field

Closes #4434
---
 trace/record/record-filter-zlib.cc | 13 +
 1 file changed, 13 insertions(+)

diff --git a/trace/record/record-filter-zlib.cc 
b/trace/record/record-filter-zlib.cc
index 87b2cfe..62f1171 100644
--- a/trace/record/record-filter-zlib.cc
+++ b/trace/record/record-filter-zlib.cc
@@ -35,6 +35,19 @@
 
 ZlibFilter::ZlibFilter() : buffer_(65536)
 {
+  stream_.next_in   = nullptr;
+  stream_.avail_in  = 0;
+  stream_.total_in  = 0;
+  stream_.next_out  = nullptr;
+  stream_.avail_out = 0;
+  stream_.total_out = 0;
+  stream_.msg   = nullptr;
+  stream_.zalloc= nullptr;
+  stream_.zfree = nullptr;
+  stream_.opaque= nullptr;
+  stream_.data_type = 0;
+  stream_.adler = 0;
+  stream_.reserved  = 0;
   inflateInit(_);
 }
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v1 1/4] DesiredSymbols.h: Initialize symbolInfo

2021-09-01 Thread Ryan Long
CID 1399627: Uninitialized pointer field

Closes #4433
---
 tester/covoar/DesiredSymbols.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tester/covoar/DesiredSymbols.h b/tester/covoar/DesiredSymbols.h
index 7ea3a9a..dbeeb2c 100644
--- a/tester/covoar/DesiredSymbols.h
+++ b/tester/covoar/DesiredSymbols.h
@@ -179,6 +179,7 @@ namespace Coverage {
  */
 SymbolInformation() :
   baseAddress( 0 ),
+  sourceFile( NULL ),
   uncoveredBranches( NULL ),
   uncoveredRanges( NULL ),
   unifiedCoverageMap( NULL )
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v1 2/4] GcovFunctionData.cc: Initialize member variables

2021-09-01 Thread Ryan Long
CID 1399640: Uninitialized pointer field

Closes #4432
---
 tester/covoar/GcovFunctionData.cc | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tester/covoar/GcovFunctionData.cc 
b/tester/covoar/GcovFunctionData.cc
index aec04ce..847439b 100644
--- a/tester/covoar/GcovFunctionData.cc
+++ b/tester/covoar/GcovFunctionData.cc
@@ -19,9 +19,13 @@ namespace Gcov {
 
   GcovFunctionData::GcovFunctionData()
   {
-numberOfArcs   = 0;
-numberOfBlocks = 0;
-coverageMap= NULL;
+id  = 0;
+checksum= 0;
+firstLineNumber = 0;
+numberOfBlocks  = 0;
+numberOfArcs= 0;
+coverageMap = NULL;
+symbolInfo  = NULL;
   }
 
   GcovFunctionData::~GcovFunctionData()
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v1 4/4] ObjdumpProcessor.h: Remove inputBuffer_m

2021-09-01 Thread Ryan Long
Accidentally got left in, so it is being removed.

CID 1506210: Uninitialized pointer field

Closes #4492
---
 tester/covoar/ObjdumpProcessor.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/tester/covoar/ObjdumpProcessor.h b/tester/covoar/ObjdumpProcessor.h
index ed36981..6a207dd 100644
--- a/tester/covoar/ObjdumpProcessor.h
+++ b/tester/covoar/ObjdumpProcessor.h
@@ -184,11 +184,6 @@ namespace Coverage {
 );
 
 /*!
- * This member variable is a buffer for input
- */
-char* inputBuffer_m;
-
-/*!
  * This member variable contains the symbols to be analyzed
  */
 DesiredSymbols& symbolsToAnalyze_m;
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


RE: [PATCH] TraceWriterQEMU.cc: Change strncpy to memcpy

2021-09-01 Thread Ryan Long



-Original Message-
From: Gedare Bloom  
Sent: Wednesday, September 1, 2021 3:21 PM
To: Ryan Long 
Cc: devel@rtems.org
Subject: Re: [PATCH] TraceWriterQEMU.cc: Change strncpy to memcpy

On Thu, Aug 19, 2021 at 7:42 AM Ryan Long  wrote:
>
> CID 1506207: Buffer not null terminated
>
> Closes #4491
> ---
>  tester/covoar/TraceWriterQEMU.cc | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tester/covoar/TraceWriterQEMU.cc 
> b/tester/covoar/TraceWriterQEMU.cc
> index c417745..be9b6e1 100644
> --- a/tester/covoar/TraceWriterQEMU.cc
> +++ b/tester/covoar/TraceWriterQEMU.cc
> @@ -106,7 +106,10 @@ namespace Trace {
>  //
>  //  Write the Header to the file
>  //
> -strncpy( header.magic, QEMU_TRACE_MAGIC, sizeof(header.magic) );
> +// The header.magic field is actually 12 bytes, but QEMU_TRACE_MAGIC is
> +// 13 bytes including the NULL.
> +const char qemu_trace_magic[13] = QEMU_TRACE_MAGIC;
> +memcpy( header.magic, qemu_trace_magic, sizeof(header.magic) );

Just to clarify, the header.magic should not be NULL terminated?
[Ryan Long] Correct. When I tried to increase the size of header.magic, it 
wouldn't run correctly.

If so, then this is fine, but I don't think the temporary local variable is 
needed though.
memcpy( header.magic, QEMU_TRACE_MAGIC, sizeof(header.magic) ); should work 
fine.

>  header.version = QEMU_TRACE_VERSION;
>  header.kind= QEMU_TRACE_KIND_RAW;  // XXX ??
>  header.sizeof_target_pc = 32;
> --
> 1.8.3.1
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH RSB v2 2/2] rtems-gcc-head-newlib-head.cfg: Add newlib patch

2021-09-03 Thread Ryan Long
Adds patch to add the -DPREFER_SIZE_OVER_SPEED flag to AArch64 tools
builds with newlib. This forces the generation of AArch64 assembly from
C sources instead of using the hand-optimized code in newlib since it
does not support ILP32. This can be removed when it is fixed upstream.

Updates #4510
---
 rtems/config/tools/rtems-gcc-head-newlib-head.cfg | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rtems/config/tools/rtems-gcc-head-newlib-head.cfg 
b/rtems/config/tools/rtems-gcc-head-newlib-head.cfg
index 4939ca5..c17895b 100644
--- a/rtems/config/tools/rtems-gcc-head-newlib-head.cfg
+++ b/rtems/config/tools/rtems-gcc-head-newlib-head.cfg
@@ -12,6 +12,9 @@
 %define newlib_expand_name sourceware-mirror-newlib-cygwin-%{newlib_version}
 %source set newlib --rsb-file=newlib-%{newlib_version}.tar.gz 
https://codeload.github.com/RTEMS/sourceware-mirror-newlib-cygwin/tar.gz/%{newlib_version}
 %hash sha512 newlib-%{newlib_version}.tar.gz 
9ded46b3077508ef05bbb4bf424777a0baa5aab9c7c0c902fb5529bb73b5b5034c35282e2dbf270cbcd44d84940a20ee270e329db4e4b501046978c18f78a11c
+%
+%patch add newlib -p1 
https://devel.rtems.org/raw-attachment/ticket/4510/0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch
+%hash sha512 0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch 
rRg7bJoWjR11FQXmSHPxF8EfsFmBnTQcXXFWGZhbKFwyTvJ8EXfGMACI33u+OuvX+gNANMOJLyv27FcyTJseKg==
 
 %define with_threads 1
 %define with_plugin 0
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH RSB v2 1/2] rtems-gcc-10-newlib-head.cfg: Add newlib patch

2021-09-03 Thread Ryan Long
Adds patch to add the -DPREFER_SIZE_OVER_SPEED flag to AArch64 tool
builds with newlib. This forces the generation of AArch64 assembly from
C sources instead of using the hand-optimized code in newlib since it
does not support ILP32. This can be removed when it is fixed upstream.

Updates #4510
---
 rtems/config/tools/rtems-gcc-10-newlib-head.cfg | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg 
b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
index 69c4fb5..85308c5 100644
--- a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
+++ b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
@@ -13,6 +13,9 @@
 %patch add gcc -p1 
https://devel.rtems.org/raw-attachment/ticket/4215/0001-nios2-Remove-custom-instruction-warnings.patch
 %hash sha512 0001-nios2-Remove-custom-instruction-warnings.patch 
afd8a5e6bdcc5b75d5fbbf558bdf56ccac400521a6eec9d88cc95f6be67c481f2dbf8faa0f6ddc1e4ac7c56a84938714d80e46e9cf80ec4b8fcd739986449881
 
+%patch add newlib -p1 
https://devel.rtems.org/raw-attachment/ticket/4510/0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch
+%hash sha512 0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch 
rRg7bJoWjR11FQXmSHPxF8EfsFmBnTQcXXFWGZhbKFwyTvJ8EXfGMACI33u+OuvX+gNANMOJLyv27FcyTJseKg==
+
 %define newlib_version 4f81149
 %define newlib_external 1
 %define newlib_expand_name sourceware-mirror-newlib-cygwin-%{newlib_version}
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


RE: [PATCH v1 3/3] rld-dwarf.cpp: Initialize member variables

2021-09-02 Thread Ryan Long
I remember prototyped_ being one that the issue was complaining about, but I 
can't remember the others. I just went ahead and added the rest of the member 
variables because Coverity doesn't always identify all the subsequent issues.

-Original Message-
From: Chris Johns  
Sent: Wednesday, September 1, 2021 10:01 PM
To: Ryan Long ; devel@rtems.org
Subject: Re: [PATCH v1 3/3] rld-dwarf.cpp: Initialize member variables

On 25/8/21 3:12 am, Ryan Long wrote:
> Initialize member variables not listed.
> 
> CID 1503019: Uninitialized scalar field.
> 
> Closes #4500
> ---
>  rtemstoolkit/rld-dwarf.cpp | 12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/rtemstoolkit/rld-dwarf.cpp b/rtemstoolkit/rld-dwarf.cpp 
> index 1eae50c..2d6f306 100644
> --- a/rtemstoolkit/rld-dwarf.cpp
> +++ b/rtemstoolkit/rld-dwarf.cpp
> @@ -679,12 +679,18 @@ namespace rld
>  machine_code_ (false),
>  external_ (false),
>  declaration_ (false),
> +prototyped_ (false),
>  inline_ (DW_INL_not_inlined),
>  entry_pc_ (0),
>  has_entry_pc_ (false),
>  pc_low_ (0),
>  pc_high_ (0),
>  ranges_ (debug),
> +name_ (),
> +linkage_name_ (),

Did coverity ask for this to be added? Why do default constructors need to be 
added?

Chris

> +decl_file_ (),
> +decl_line_ (0),
> +call_file_ (),
>  call_line_ (0)
>  {
>dwarf_bool db;
> @@ -819,6 +825,7 @@ namespace rld
>  machine_code_ (orig.machine_code_),
>  external_ (orig.external_),
>  declaration_ (orig.declaration_),
> +prototyped_ (orig.prototyped_),
>  inline_ (orig.inline_),
>  entry_pc_ (orig.entry_pc_),
>  has_entry_pc_ (orig.has_entry_pc_), @@ -827,6 +834,8 @@ 
> namespace rld
>  ranges_ (orig.ranges_),
>  name_ (orig.name_),
>  linkage_name_ (orig.linkage_name_),
> +decl_file_ (orig.decl_file_),
> +decl_line_ (orig.decl_line_),
>  call_file_ (orig.call_file_),
>  call_line_ (orig.call_line_)
>  {
> @@ -986,7 +995,10 @@ namespace rld
>  ranges_ = rhs.ranges_;
>  name_ = rhs.name_;
>  linkage_name_ = rhs.linkage_name_;
> +decl_file_ = rhs.decl_file_;
> +decl_line_ = rhs.decl_line_;
>  call_file_ = rhs.call_file_;
> +call_line_ = rhs.call_line_;
>}
>return *this;
>  }
> 
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 04/10] CoverageMapBase.cc: Fix formatting

2021-09-02 Thread Ryan Long
---
 tester/covoar/CoverageMapBase.cc | 261 ---
 1 file changed, 159 insertions(+), 102 deletions(-)

diff --git a/tester/covoar/CoverageMapBase.cc b/tester/covoar/CoverageMapBase.cc
index 334426b..7073260 100644
--- a/tester/covoar/CoverageMapBase.cc
+++ b/tester/covoar/CoverageMapBase.cc
@@ -18,98 +18,109 @@
 
 namespace Coverage {
 
-  AddressInfo::AddressInfo ()
-: isStartOfInstruction (false),
-  wasExecuted (false),
-  isBranch (false),
-  isNop (false),
-  wasTaken (false),
-  wasNotTaken (false)
+  AddressInfo::AddressInfo()
+: isStartOfInstruction( false ),
+  wasExecuted( false ),
+  isBranch( false ),
+  isNop( false ),
+  wasTaken( false ),
+  wasNotTaken( false )
   {
   }
 
-  AddressRange::AddressRange ()
-: lowAddress(0),
-  highAddress(0)
+  AddressRange::AddressRange()
+: lowAddress( 0 ),
+  highAddress( 0 )
   {
   }
 
-  AddressRange::AddressRange (const std::string& name,
-  uint32_t   lowAddress,
-  uint32_t   highAddress)
-: fileName (name),
-  lowAddress (lowAddress),
-  highAddress (highAddress)
+  AddressRange::AddressRange(
+const std::string& name,
+uint32_t   lowAddress,
+uint32_t   highAddress)
+: fileName( name ),
+  lowAddress( lowAddress ),
+  highAddress( highAddress )
   {
-info.resize( size( ) );
+info.resize( size() );
   }
 
-  size_t AddressRange::size () const
+  size_t AddressRange::size() const
   {
 return highAddress - lowAddress + 1;
   }
 
-  bool AddressRange::inside (uint32_t address) const
+  bool AddressRange::inside( uint32_t address ) const
   {
 return address >= lowAddress && address <= highAddress;
   }
 
-  AddressInfo& AddressRange::get (uint32_t address)
+  AddressInfo& AddressRange::get( uint32_t address )
   {
-if ( !inside( address ) )
+if ( !inside( address ) ) {
   throw rld::error( "address outside range", "AddressRange::get" );
+}
+
 size_t slot = address - lowAddress;
-if (slot >= info.size ())
+
+if ( slot >= info.size () ) {
   throw rld::error( "address slot not found", "AddressRange::get" );
+}
+
 return info[slot];
   }
 
-  const AddressInfo& AddressRange::get (uint32_t address) const
+  const AddressInfo& AddressRange::get( uint32_t address ) const
   {
-if ( !inside( address ) )
+if ( !inside( address ) ) {
   throw rld::error( "address outside range", "AddressRange::get" );
+}
+
 size_t slot = address - lowAddress;
-if (slot >= info.size ())
+
+if ( slot >= info.size() ) {
   throw rld::error( "address slot not found", "AddressRange::get" );
+}
+
 return info[slot];
   }
 
-  void AddressRange::dump (std::ostream& out, bool show_slots) const
+  void AddressRange::dump( std::ostream& out, bool show_slots ) const
   {
 rtems::utils::ostream_guard old_state( out );
 
-out << std::hex << std::setfill('0')
-<< "Address range: low = " << std::setw(8) << lowAddress
-<< " high = " << std::setw(8) << highAddress
+out << std::hex << std::setfill( '0' )
+<< "Address range: low = " << std::setw( 8 ) << lowAddress
+<< " high = " << std::setw( 8 ) << highAddress
 << std::endl;
+
 if (show_slots) {
   size_t slot = 0;
-  for (auto& i : info) {
-out << std::hex << std::setfill('0')
-<< "0x" << std::setw(8) << slot++ + lowAddress
+
+  for ( auto& i : info ) {
+out << std::hex << std::setfill( '0' )
+<< "0x" << std::setw( 8 ) << slot++ + lowAddress
 << "- isStartOfInstruction:"
-<< (char*) (i.isStartOfInstruction ? "yes" : "no")
+<< (char*) ( i.isStartOfInstruction ? "yes" : "no" )
 << " wasExecuted:"
-<< (char*) (i.wasExecuted ? "yes" : "no")
-<< std::endl
-<< "   isBranch:"
-<< (char*) (i.isBranch ? "yes" : "no")
+<< (char*) ( i.wasExecuted ? "yes" : "no" )
+<< "\n   isBranch:"
+<< (char*) ( i.isBranch ? "yes" : "no" )
 << " wasTaken:"
-<< (char*) (i.wasTaken ? "yes" : "no")
+<< (char*) ( i.wasTaken ? "yes" : "no" )
 << " wasNotTaken:"
-<< (char*) (i.wasNotTaken ? "yes" : "no")
-<< std::dec << std::setfill(' ')
+<< (char*) ( i.wasNotTaken ? "yes" : "no" )
+<< std::dec << std::setfill( ' ' )
 << std::endl;
   }
 }
-
   }
 
   CoverageMapBase::CoverageMapBase(
 const std::string& exefileName,
 uint32_t   low,
 uint32_t   high
-) : exefileName (exefileName)
+  ) : exefileName( exefileName )
   {
 Ranges.push_back( AddressRange( exefileName, low, high ) );
   }
@@ -125,30 +136,38 @@ namespace Coverage {
 
   bool 

[PATCH v1 05/10] CoverageFactory.h: Fix formatting

2021-09-02 Thread Ryan Long
---
 tester/covoar/CoverageFactory.h | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/tester/covoar/CoverageFactory.h b/tester/covoar/CoverageFactory.h
index f71860d..52443e8 100644
--- a/tester/covoar/CoverageFactory.h
+++ b/tester/covoar/CoverageFactory.h
@@ -32,9 +32,7 @@ namespace Coverage {
*
*  @return Returns a coverage file format.
*/
-  CoverageFormats_t CoverageFormatToEnum(
-const std::string& format
-  );
+  CoverageFormats_t CoverageFormatToEnum( const std::string& format );
 
   /*!
*  This method returns an instance of a Coverage File Reader class
@@ -44,9 +42,7 @@ namespace Coverage {
*
*  @return Returns a Coverage File Reader class instance.
*/
-  CoverageReaderBase* CreateCoverageReader(
-CoverageFormats_t format
-  );
+  CoverageReaderBase* CreateCoverageReader( CoverageFormats_t format );
 
   /*!
*  This method returns an instance of a Coverage File Writer class
@@ -56,9 +52,7 @@ namespace Coverage {
*
*  @return Returns a Coverage File Writer class instance.
*/
-  CoverageWriterBase* CreateCoverageWriter(
-CoverageFormats_t format
-  );
+  CoverageWriterBase* CreateCoverageWriter( CoverageFormats_t format );
 }
 
 #endif
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 00/10] Convert and reformat rtems-tools pt. 1

2021-09-02 Thread Ryan Long
Hi,

For this and the following series of patches I followed this series of
steps.

1. Convert a file from the C way of doing things to C++
2. Go through all the files that had to do with the converted file and
make the formatting consistent.

Thanks,
Ryan

Ryan Long (10):
  CoverageMap.cc: Fix formatting
  CoverageReader: Convert to C++
  CoverageFactory.cc: Fix formatting
  CoverageMapBase.cc: Fix formatting
  CoverageFactory.h: Fix formatting
  CoverageMapBase.h: Fix formatting
  CoverageReaderQEMU.cc: Fix formatting
  CoverageReaderRTEMS.cc: Fix formatting
  CoverageReaderSkyeye.cc: Fix formatting
  CoverageReaderTSIM.cc: Fix formatting

 tester/covoar/CoverageFactory.cc  |  18 ++-
 tester/covoar/CoverageFactory.h   |  12 +-
 tester/covoar/CoverageMap.cc  |   2 +-
 tester/covoar/CoverageMapBase.cc  | 261 +-
 tester/covoar/CoverageMapBase.h   |  66 ++---
 tester/covoar/CoverageReaderBase.h|   2 +-
 tester/covoar/CoverageReaderQEMU.cc   |  57 +++-
 tester/covoar/CoverageReaderQEMU.h|   4 +-
 tester/covoar/CoverageReaderRTEMS.cc  |  44 +++---
 tester/covoar/CoverageReaderRTEMS.h   |   2 +-
 tester/covoar/CoverageReaderSkyeye.cc |  41 +++---
 tester/covoar/CoverageReaderSkyeye.h  |   2 +-
 tester/covoar/CoverageReaderTSIM.cc   |  31 ++--
 tester/covoar/CoverageReaderTSIM.h|   4 +-
 14 files changed, 308 insertions(+), 238 deletions(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 03/10] CoverageFactory.cc: Fix formatting

2021-09-02 Thread Ryan Long
---
 tester/covoar/CoverageFactory.cc | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tester/covoar/CoverageFactory.cc b/tester/covoar/CoverageFactory.cc
index e6c3774..89f8376 100644
--- a/tester/covoar/CoverageFactory.cc
+++ b/tester/covoar/CoverageFactory.cc
@@ -25,17 +25,21 @@ Coverage::CoverageFormats_t Coverage::CoverageFormatToEnum(
   const std::string& format
 )
 {
-  if (format == "QEMU")
+  if ( format == "QEMU" ) {
 return COVERAGE_FORMAT_QEMU;
+  }
 
-  if (format == "RTEMS")
+  if ( format == "RTEMS" ) {
 return COVERAGE_FORMAT_RTEMS;
+  }
 
-  if (format == "Skyeye")
+  if (format == "Skyeye") {
 return COVERAGE_FORMAT_SKYEYE;
+  }
 
-  if (format == "TSIM")
+  if ( format == "TSIM" ) {
 return COVERAGE_FORMAT_TSIM;
+  }
 
   std::ostringstream what;
   what << format << " is an unknown coverage format "
@@ -47,7 +51,7 @@ Coverage::CoverageReaderBase* Coverage::CreateCoverageReader(
   CoverageFormats_t format
 )
 {
-  switch (format) {
+  switch ( format ) {
 case COVERAGE_FORMAT_QEMU:
   return new Coverage::CoverageReaderQEMU();
 case COVERAGE_FORMAT_RTEMS:
@@ -66,7 +70,7 @@ Coverage::CoverageWriterBase* Coverage::CreateCoverageWriter(
   CoverageFormats_t format
 )
 {
-  switch (format) {
+  switch ( format ) {
 case COVERAGE_FORMAT_RTEMS:
   return new Coverage::CoverageWriterRTEMS();
 case COVERAGE_FORMAT_SKYEYE:
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 01/10] CoverageMap.cc: Fix formatting

2021-09-02 Thread Ryan Long
---
 tester/covoar/CoverageMap.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tester/covoar/CoverageMap.cc b/tester/covoar/CoverageMap.cc
index b470fea..3e0b9ce 100644
--- a/tester/covoar/CoverageMap.cc
+++ b/tester/covoar/CoverageMap.cc
@@ -13,7 +13,7 @@ namespace Coverage {
 const std::string& exefileName,
 uint32_t   low,
 uint32_t   high
-  ) : CoverageMapBase(exefileName, low, high)
+  ) : CoverageMapBase( exefileName, low, high )
   {
   }
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 02/10] CoverageReader: Convert to C++

2021-09-02 Thread Ryan Long
---
 tester/covoar/CoverageFactory.cc  | 10 +-
 tester/covoar/CoverageFactory.h   |  2 +-
 tester/covoar/CoverageReaderBase.h|  2 +-
 tester/covoar/CoverageReaderQEMU.cc   | 35 ++-
 tester/covoar/CoverageReaderQEMU.h|  4 +++-
 tester/covoar/CoverageReaderRTEMS.cc  | 20 +---
 tester/covoar/CoverageReaderRTEMS.h   |  2 +-
 tester/covoar/CoverageReaderSkyeye.cc | 20 +---
 tester/covoar/CoverageReaderSkyeye.h  |  2 +-
 tester/covoar/CoverageReaderTSIM.cc   | 21 +++--
 tester/covoar/CoverageReaderTSIM.h|  4 +++-
 11 files changed, 54 insertions(+), 68 deletions(-)

diff --git a/tester/covoar/CoverageFactory.cc b/tester/covoar/CoverageFactory.cc
index 991ba8f..e6c3774 100644
--- a/tester/covoar/CoverageFactory.cc
+++ b/tester/covoar/CoverageFactory.cc
@@ -22,19 +22,19 @@
 #include "CoverageWriterTSIM.h"
 
 Coverage::CoverageFormats_t Coverage::CoverageFormatToEnum(
-  const char* const format
+  const std::string& format
 )
 {
-  if (!strcmp( format, "QEMU" ))
+  if (format == "QEMU")
 return COVERAGE_FORMAT_QEMU;
 
-  if (!strcmp( format, "RTEMS" ))
+  if (format == "RTEMS")
 return COVERAGE_FORMAT_RTEMS;
 
-  if (!strcmp( format, "Skyeye" ))
+  if (format == "Skyeye")
 return COVERAGE_FORMAT_SKYEYE;
 
-  if (!strcmp( format, "TSIM" ))
+  if (format == "TSIM")
 return COVERAGE_FORMAT_TSIM;
 
   std::ostringstream what;
diff --git a/tester/covoar/CoverageFactory.h b/tester/covoar/CoverageFactory.h
index 4770d78..f71860d 100644
--- a/tester/covoar/CoverageFactory.h
+++ b/tester/covoar/CoverageFactory.h
@@ -33,7 +33,7 @@ namespace Coverage {
*  @return Returns a coverage file format.
*/
   CoverageFormats_t CoverageFormatToEnum(
-const char* const format
+const std::string& format
   );
 
   /*!
diff --git a/tester/covoar/CoverageReaderBase.h 
b/tester/covoar/CoverageReaderBase.h
index 332fc4d..7064b8d 100644
--- a/tester/covoar/CoverageReaderBase.h
+++ b/tester/covoar/CoverageReaderBase.h
@@ -39,7 +39,7 @@ namespace Coverage {
  * associated executable
  */
 virtual void processFile(
-  const char* const file,
+  const std::string&file,
   ExecutableInfo* const executableInformation
 ) = 0;
 
diff --git a/tester/covoar/CoverageReaderQEMU.cc 
b/tester/covoar/CoverageReaderQEMU.cc
index a44097d..cef09b3 100644
--- a/tester/covoar/CoverageReaderQEMU.cc
+++ b/tester/covoar/CoverageReaderQEMU.cc
@@ -20,12 +20,6 @@
 
 #include "qemu-traces.h"
 
-#if HAVE_OPEN64
-#define OPEN fopen64
-#else
-#define OPEN fopen
-#endif
-
 namespace Coverage {
 
   CoverageReaderQEMU::CoverageReaderQEMU()
@@ -38,14 +32,13 @@ namespace Coverage {
   }
 
   void CoverageReaderQEMU::processFile(
-const char* const file,
+const std::string&file,
 ExecutableInfo* const executableInformation
   )
   {
 struct trace_header header;
 uintptr_t   i;
-int status;
-FILE*   traceFile;
+std::ifstream   traceFile;
 uint8_t taken;
 uint8_t notTaken;
 uint8_t branchInfo;
@@ -57,16 +50,15 @@ namespace Coverage {
 //
 // Open the coverage file and read the header.
 //
-traceFile = ::OPEN( file, "r" );
-if (!traceFile) {
+traceFile.open( file );
+if ( !traceFile.is_open() ) {
   std::ostringstream what;
   what << "Unable to open " << file;
   throw rld::error( what, "CoverageReaderQEMU::processFile" );
 }
 
-status = ::fread( , sizeof(trace_header), 1, traceFile );
-if (status != 1) {
-  ::fclose( traceFile );
+traceFile.read( (char *) , sizeof( trace_header ) );
+if ( traceFile.fail() || traceFile.gcount() != sizeof( trace_header ) ) {
   std::ostringstream what;
   what << "Unable to read header from " << file;
   throw rld::error( what, "CoverageReaderQEMU::processFile" );
@@ -80,22 +72,16 @@ namespace Coverage {
   CoverageMapBase *aCoverageMap = NULL;
   struct trace_entry  entries[ENTRIES];
   struct trace_entry  *entry;
-  int num_entries;
-
 
   // Read and process each line of the coverage file.
-  num_entries = ::fread(
-entries,
-sizeof(struct trace_entry),
-ENTRIES,
-traceFile
-  );
-  if (num_entries == 0)
+  traceFile.read( (char *) entries, sizeof( struct trace_entry ) );
+  if ( traceFile.gcount() == 0 ) {
 break;
+  }
 
   // Get the coverage map for each entry.  Note that the map is
   // the same for each entry in the coverage map
-  for (int count=0; count
+
 #include "CoverageReaderBase.h"
 #include "ExecutableInfo.h"
 
@@ -37,7 +39,7 @@ TBD
 
 /* Inherit documentation from base class. */
 void processFile(
-  const char* const file,
+  const std::string&file,
   ExecutableInfo* const executableInformation

[PATCH v1 09/10] CoverageReaderSkyeye.cc: Fix formatting

2021-09-02 Thread Ryan Long
---
 tester/covoar/CoverageReaderSkyeye.cc | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/tester/covoar/CoverageReaderSkyeye.cc 
b/tester/covoar/CoverageReaderSkyeye.cc
index de0d4ad..abb3878 100644
--- a/tester/covoar/CoverageReaderSkyeye.cc
+++ b/tester/covoar/CoverageReaderSkyeye.cc
@@ -64,13 +64,13 @@ namespace Coverage {
 //
 // Read and process each line of the coverage file.
 //
-for (i = 0; i < length; i += 8) {
+for ( i = 0; i < length; i += 8 ) {
   coverageFile.read( (char *) , sizeof( uint8_t ) );
   if ( coverageFile.gcount() != sizeof( uint8_t ) ) {
 std::cerr << "CoverageReaderSkyeye::ProcessFile - breaking after 0x"
-  << std::hex << std::setfill('0')
-  << std::setw(8) << i
-  << std::setfill(' ') << std::dec
+  << std::hex << std::setfill( '0' )
+  << std::setw( 8 ) << i
+  << std::setfill( ' ' ) << std::dec
   << " in " << file
   << std::endl;
 break;
@@ -82,9 +82,12 @@ namespace Coverage {
   //
   // NOTE: This method ONLY works for Skyeye in 32-bit mode.
   //
-  if (cover & 0x01) {
-aCoverageMap = executableInformation->getCoverageMap( baseAddress + i 
);
-if (aCoverageMap) {
+  if ( cover & 0x01 ) {
+aCoverageMap = executableInformation->getCoverageMap(
+  baseAddress + i
+);
+
+if ( aCoverageMap ) {
   aCoverageMap->setWasExecuted( baseAddress + i );
   aCoverageMap->setWasExecuted( baseAddress + i + 1 );
   aCoverageMap->setWasExecuted( baseAddress + i + 2 );
@@ -92,11 +95,11 @@ namespace Coverage {
 }
   }
 
-  if (cover & 0x10) {
+  if ( cover & 0x10 ) {
 aCoverageMap = executableInformation->getCoverageMap(
   baseAddress + i + 4
 );
-if (aCoverageMap) {
+if ( aCoverageMap ) {
   aCoverageMap->setWasExecuted( baseAddress + i + 4 );
   aCoverageMap->setWasExecuted( baseAddress + i + 5 );
   aCoverageMap->setWasExecuted( baseAddress + i + 6 );
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 10/10] CoverageReaderTSIM.cc: Fix formatting

2021-09-02 Thread Ryan Long
---
 tester/covoar/CoverageReaderTSIM.cc | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tester/covoar/CoverageReaderTSIM.cc 
b/tester/covoar/CoverageReaderTSIM.cc
index 9c6ff7d..11f0be6 100644
--- a/tester/covoar/CoverageReaderTSIM.cc
+++ b/tester/covoar/CoverageReaderTSIM.cc
@@ -61,7 +61,7 @@ namespace Coverage {
 break;
   }
 
-  for (i = 0; i < 0x80; i += 4) {
+  for ( i = 0; i < 0x80; i += 4 ) {
 unsigned int a;
 
 coverageFile >> std::hex >> cover >> std::dec;
@@ -69,9 +69,9 @@ namespace Coverage {
   std::cerr << "CoverageReaderTSIM: WARNING! Short line in "
 << file
 << " at address 0x"
-<< std::hex << std::setfill('0')
+<< std::hex << std::setfill( '0' )
 << baseAddress
-<< std::setfill(' ') << std::dec
+<< std::setfill( ' ' ) << std::dec
 << std::endl;
   break;
 }
@@ -82,8 +82,10 @@ namespace Coverage {
 //
 a = baseAddress + i;
 aCoverageMap = executableInformation->getCoverageMap( a );
-if ( !aCoverageMap )
+if ( !aCoverageMap ) {
   continue;
+}
+
 if ( cover & 0x01 ) {
   aCoverageMap->setWasExecuted( a );
   aCoverageMap->setWasExecuted( a + 1 );
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 08/10] CoverageReaderRTEMS.cc: Fix formatting

2021-09-02 Thread Ryan Long
---
 tester/covoar/CoverageReaderRTEMS.cc | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/tester/covoar/CoverageReaderRTEMS.cc 
b/tester/covoar/CoverageReaderRTEMS.cc
index e869fc2..6331a81 100644
--- a/tester/covoar/CoverageReaderRTEMS.cc
+++ b/tester/covoar/CoverageReaderRTEMS.cc
@@ -35,13 +35,13 @@ namespace Coverage {
 ExecutableInfo* const executableInformation
   )
   {
-CoverageMapBase* aCoverageMap = NULL;
-uintptr_tbaseAddress;
-uint8_t  cover;
-std::ifstreamcoverageFile;
-rtems_coverage_map_header_t  header;
-uintptr_ti;
-uintptr_tlength;
+CoverageMapBase*aCoverageMap = NULL;
+uintptr_t   baseAddress;
+uint8_t cover;
+std::ifstream   coverageFile;
+rtems_coverage_map_header_t header;
+uintptr_t   i;
+uintptr_t   length;
 
 //
 // Open the coverage file and read the header.
@@ -66,13 +66,13 @@ namespace Coverage {
 //
 // Read and process each line of the coverage file.
 //
-for (i = 0; i < length; i++) {
+for ( i = 0; i < length; i++ ) {
   coverageFile.read( (char *) , sizeof( uint8_t ) );
   if ( coverageFile.fail() ) {
 std::cerr << "breaking after 0x"
-  << std::hex << std::setfill('0')
-  << std::setw(8) << i
-  << std::setfill(' ') << std::dec
+  << std::hex << std::setfill( '0' )
+  << std::setw( 8 ) << i
+  << std::setfill( ' ' ) << std::dec
   << " in " << file
   << std::endl;
 break;
@@ -82,9 +82,9 @@ namespace Coverage {
   // Obtain the coverage map containing the address and
   // mark the address as executed.
   //
-  if (cover) {
+  if ( cover ) {
 aCoverageMap = executableInformation->getCoverageMap( baseAddress + i 
);
-if (aCoverageMap)
+if ( aCoverageMap )
   aCoverageMap->setWasExecuted( baseAddress + i );
   }
 }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


RE: [PATCH rtems-tools v1 01/10] CoverageWriter: Convert to C++

2021-09-09 Thread Ryan Long
Got this fixed when I tested on MacOS. I'll change that "\n" to std::endl.

-Original Message-
From: devel  On Behalf Of Chris Johns
Sent: Wednesday, September 8, 2021 5:44 PM
To: devel@rtems.org
Subject: Re: [PATCH rtems-tools v1 01/10] CoverageWriter: Convert to C++



On 9/9/21 2:44 am, Ryan Long wrote:
> ---
>  tester/covoar/CoverageWriterBase.h|  4 +++-
>  tester/covoar/CoverageWriterRTEMS.cc  | 26 +++---
>  tester/covoar/CoverageWriterRTEMS.h   |  4 +++-
>  tester/covoar/CoverageWriterSkyeye.cc | 33 
> ++---  tester/covoar/CoverageWriterSkyeye.h  |  4 
> +++-
>  tester/covoar/CoverageWriterTSIM.cc   | 23 +++
>  tester/covoar/CoverageWriterTSIM.h|  4 +++-
>  7 files changed, 56 insertions(+), 42 deletions(-)
> 
> diff --git a/tester/covoar/CoverageWriterBase.h 
> b/tester/covoar/CoverageWriterBase.h
> index e43a45b..fca501a 100644
> --- a/tester/covoar/CoverageWriterBase.h
> +++ b/tester/covoar/CoverageWriterBase.h
> @@ -9,6 +9,8 @@
>  
>  #include 
>  
> +#include 
> +
>  #include "CoverageMapBase.h"
>  
>  namespace Coverage {
> @@ -46,7 +48,7 @@ namespace Coverage {
>   *  @return Returns TRUE if the method succeeded and FALSE if it failed.
>   */
>  virtual void writeFile(
> -  const char* const file,
> +  const std::string& file,
>CoverageMapBase*  coverage,
>uint32_t  lowAddress,
>uint32_t  highAddress
> diff --git a/tester/covoar/CoverageWriterRTEMS.cc 
> b/tester/covoar/CoverageWriterRTEMS.cc
> index 48e8fd1..3332cd4 100644
> --- a/tester/covoar/CoverageWriterRTEMS.cc
> +++ b/tester/covoar/CoverageWriterRTEMS.cc
> @@ -10,6 +10,7 @@
>  #include 
>  
>  #include 
> +#include 
>  #include 
>  
>  #include 
> @@ -28,23 +29,23 @@ namespace Coverage {
>}
>  
>void CoverageWriterRTEMS::writeFile(
> -const char* const file,
> +const std::string& file,
>  CoverageMapBase*  coverage,
>  uint32_t  lowAddress,
>  uint32_t  highAddress
>)
>{
> -FILE*   coverageFile;
> +std::ofstream   coverageFile;
>  uint32_ta;
> -int status;
>  uint8_t cover;
>  rtems_coverage_map_header_t header;
> +long intbytes_before;

This need to change. Please review the fixes I added for the places this 
happened.

Building this on MacOS and FreeBSD should show the error.

>  /*
>   *  read the file and update the coverage map passed in
>   */
> -coverageFile = ::fopen( file, "w" );
> -if ( !coverageFile ) {
> +coverageFile.open( file );
> +if ( !coverageFile.is_open() ) {
>std::ostringstream what;
>what << "Unable to open " << file;
>throw rld::error( what, "CoverageWriterRTEMS::writeFile" ); @@ 
> -58,9 +59,10 @@ namespace Coverage {
>  header.end   = highAddress;
>  strcpy( header.desc, "RTEMS Coverage Data" );
>  
> -status = ::fwrite(, 1, sizeof(header), coverageFile);
> -if (status != sizeof(header)) {
> -  ::fclose( coverageFile );
> +bytes_before = coverageFile.tellp();
> +
> +coverageFile.write( (char *) , sizeof( header ) );
> +if ( coverageFile.tellp() - bytes_before != sizeof( header ) ) {

clang does not like this line

>std::ostringstream what;
>what << "Unable to write header to " << file;
>throw rld::error( what, "CoverageWriterRTEMS::writeFile" ); @@ 
> -68,8 +70,11 @@ namespace Coverage {
>  
>  for ( a=lowAddress ; a < highAddress ; a++ ) {
>cover  = ((coverage->wasExecuted( a )) ? 0x01 : 0);
> -  status = fwrite(, 1, sizeof(cover), coverageFile);
> -  if (status != sizeof(cover)) {
> +
> +  bytes_before = coverageFile.tellp();
> +
> +  coverageFile.write( (char *) , sizeof( cover ) );
> +  if ( coverageFile.tellp() - bytes_before != sizeof( cover ) ) {
>  std::cerr << "CoverageWriterRTEMS::writeFile - write to "
><< file
><< " at address 0x%"
> @@ -81,6 +86,5 @@ namespace Coverage {
>}
>  }
>  
> -::fclose( coverageFile );
>}
>  }
> diff --git a/tester/covoar/CoverageWriterRTEMS.h 
> b/tester/covoar/CoverageWriterRTEMS.h
> index b66d2fa..c760936 100644
> --- a/tester/covoar/CoverageWriterRTEMS.h
> +++ b/tester/covoar/CoverageWriterRTEMS.h
> @@ -7,6 +7,8

RE: [PATCH rtems-tools v1 02/10] covoar.cc: Convert to C++

2021-09-09 Thread Ryan Long
ExecutableInfo takes a const char* const parameter and initializes a string. I 
tried to take off the c_str(), but it wouldn't build then. Is it alright for 
that to temporarily stay there until I make a sweep through ExecutableInfo.cc? 
Or do you want me to go ahead and do that, and add it to this patchset?

I was able to remove the c_str() from the CoverageFormatToEnum() call though.

-Original Message-
From: devel  On Behalf Of Chris Johns
Sent: Wednesday, September 8, 2021 5:46 PM
To: devel@rtems.org
Subject: Re: [PATCH rtems-tools v1 02/10] covoar.cc: Convert to C++



On 9/9/21 2:44 am, Ryan Long wrote:
> Got rid of C-strings, changed FILE pointer to ifstream.
> ---
>  tester/covoar/covoar.cc | 52 
> +++--
>  1 file changed, 24 insertions(+), 28 deletions(-)
> 
> diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc index 
> f9d4814..746add1 100644
> --- a/tester/covoar/covoar.cc
> +++ b/tester/covoar/covoar.cc
> @@ -45,11 +45,11 @@ typedef std::list CoverageNames;  
> typedef std::list Executables;  typedef 
> std::string option_error;
>  
> -bool FileIsReadable( const char *f1 )
> +bool FileIsReadable( const std::string& f1 )
>  {
>struct STAT buf1;
>  
> -  if (STAT( f1,  ) == -1)
> +  if (STAT( f1.c_str(),  ) == -1)
>  return false;
>  
>if (buf1.st_size == 0)
> @@ -177,17 +177,14 @@ int covoar(
>std::string   coverageExtension = "cov";
>Coverage::CoverageFormats_t   coverageFormat = 
> Coverage::COVERAGE_FORMAT_QEMU;
>Coverage::CoverageReaderBase* coverageReader = NULL;
> -  char* executable = NULL;
> -  const char*   explanations = NULL;
> -  const char*   gcnosFileName = NULL;
> -  char  gcnoFileName[FILE_NAME_LENGTH];
> -  char  gcdaFileName[FILE_NAME_LENGTH];
> -  char  gcovBashCommand[256];
> +  std::string   explanations;
> +  std::string   gcnosFileName;
> +  std::string   gcnoFileName;
>std::string   target;
> -  const char*   format = "QEMU";
> -  FILE* gcnosFile = NULL;
> +  std::string   format = "QEMU";
> +  std::ifstream gcnosFile;
>Gcov::GcovData*   gcovFile;
> -  const char*   singleExecutable = NULL;
> +  std::string   singleExecutable;
>rld::process::tempfileobjdumpFile( ".dmp" );
>rld::process::tempfileerr( ".err" );
>rld::process::tempfilesyms( ".syms" );
> @@ -203,7 +200,6 @@ int covoar(
>std::string   outputDirectory = ".";
>Coverage::DesiredSymbols  symbolsToAnalyze;
>bool  branchInfoAvailable = false;
> -  //Target::TargetBase*   targetInfo;
>  
>//
>// Process command line options.
> @@ -243,7 +239,7 @@ int covoar(
>/*
> * Has path to explanations.txt been specified.
> */
> -  if ( !explanations )
> +  if ( explanations.empty() )
>  throw option_error( "explanations -E" );
>  
>/*
> @@ -272,7 +268,7 @@ int covoar(
>}
>  
>if (verbose) {
> -if (singleExecutable) {
> +if (!singleExecutable.empty()) {
>std::cerr << "Processing a single executable and multiple coverage 
> files"
>  << std::endl;
>  } else {
> @@ -287,7 +283,7 @@ int covoar(
>  for (const auto& cname : coverageFileNames) {
>std::cerr << "Coverage file " << cname
>  << " for executable: " << (*eitr)->getFileName() << 
> std::endl;
> -  if (!singleExecutable)
> +  if (singleExecutable.empty())
>  eitr++;
>  }
>}
> @@ -309,7 +305,7 @@ int covoar(
>  
>// If a single executable was specified, process the remaining
>// arguments as coverage file names.
> -  if (singleExecutable) {
> +  if (!singleExecutable.empty()) {
>  
>  // Ensure that the executable is readable.
>  if (!FileIsReadable( singleExecutable )) { @@ -332,14 +328,14 @@ 
> int covoar(
>if (!coverageFileNames.empty()) {
>  if ( !dynamicLibrary.empty() ) {
>executableInfo = new Coverage::ExecutableInfo(
> -singleExecutable,
> +singleExecutable.c_str(),
>  dynamicLibrary,
>  verbose,
>  symbolsToAnalyze
>);
> 

[PATCH rtems-tools v2 06/10] CoverageWriterRTEMS.h: Fix formatting

2021-09-10 Thread Ryan Long
---
 tester/covoar/CoverageWriterRTEMS.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tester/covoar/CoverageWriterRTEMS.h 
b/tester/covoar/CoverageWriterRTEMS.h
index c760936..9110303 100644
--- a/tester/covoar/CoverageWriterRTEMS.h
+++ b/tester/covoar/CoverageWriterRTEMS.h
@@ -36,9 +36,9 @@ namespace Coverage {
 /* Inherit documentation from base class. */
 void writeFile(
   const std::string& file,
-  CoverageMapBase*  coverage,
-  uint32_t  lowAddress,
-  uint32_t  highAddress
+  CoverageMapBase*   coverage,
+  uint32_t   lowAddress,
+  uint32_t   highAddress
 );
   };
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v2 07/10] CoverageWriterSkyeye.cc: Fix formatting

2021-09-10 Thread Ryan Long
---
 tester/covoar/CoverageWriterSkyeye.cc | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tester/covoar/CoverageWriterSkyeye.cc 
b/tester/covoar/CoverageWriterSkyeye.cc
index fcc7052..f7c71c4 100644
--- a/tester/covoar/CoverageWriterSkyeye.cc
+++ b/tester/covoar/CoverageWriterSkyeye.cc
@@ -54,9 +54,9 @@ namespace Coverage {
 }
 
 /* clear out the header and fill it in */
-memset( , 0, sizeof(header) );
+memset( , 0, sizeof( header ) );
 header.ver   = 0x1;
-header.header_length = sizeof(header);
+header.header_length = sizeof( header );
 header.prof_start= lowAddress;
 header.prof_end  = highAddress;
 strcpy( header.desc, "Skyeye Coverage Data" );
@@ -81,9 +81,9 @@ namespace Coverage {
 std::ostringstream what;
 what << "write to " << file
  << " at address 0x"
- << std::hex << std::setfill('0')
- << std::setw(8) << a
- << std::setfill(' ') << std::dec
+ << std::hex << std::setfill( '0' )
+ << std::setw( 8 ) << a
+ << std::setfill( ' ' ) << std::dec
  << "failed";
 throw rld::error( what, "CoverageWriterSkyeye::writeFile" );
   }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v2 03/10] CoverageWriterBase.h: Fix formatting

2021-09-10 Thread Ryan Long
---
 tester/covoar/CoverageWriterBase.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tester/covoar/CoverageWriterBase.h 
b/tester/covoar/CoverageWriterBase.h
index fca501a..ee8c148 100644
--- a/tester/covoar/CoverageWriterBase.h
+++ b/tester/covoar/CoverageWriterBase.h
@@ -49,9 +49,9 @@ namespace Coverage {
  */
 virtual void writeFile(
   const std::string& file,
-  CoverageMapBase*  coverage,
-  uint32_t  lowAddress,
-  uint32_t  highAddress
+  CoverageMapBase*   coverage,
+  uint32_t   lowAddress,
+  uint32_t   highAddress
 ) = 0;
   };
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v2 04/10] covoar.cc: Fix formatting

2021-09-10 Thread Ryan Long
---
 tester/covoar/covoar.cc | 300 +++-
 1 file changed, 167 insertions(+), 133 deletions(-)

diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc
index 710294b..ec126d6 100644
--- a/tester/covoar/covoar.cc
+++ b/tester/covoar/covoar.cc
@@ -35,25 +35,27 @@
 #define STAT stat
 #endif
 
-#if defined(_WIN32) || defined(__CYGWIN__)
-  #define kill(p,s) raise(s)
+#if defined( _WIN32 ) || defined( __CYGWIN__ )
+  #define kill( p,s ) raise( s )
 #endif
 
 #define MAX_LINE_LENGTH 512
 
-typedef std::list CoverageNames;
+typedef std::list   CoverageNames;
 typedef std::list Executables;
-typedef std::string option_error;
+typedef std::string  OptionError;
 
 bool FileIsReadable( const std::string& f1 )
 {
   struct STAT buf1;
 
-  if (STAT( f1.c_str(),  ) == -1)
+  if ( STAT( f1.c_str(),  ) == -1 ) {
 return false;
+  }
 
-  if (buf1.st_size == 0)
+  if ( buf1.st_size == 0 ) {
 return false;
+  }
 
   // XXX check permission ??
   return true;
@@ -63,75 +65,92 @@ bool FileIsReadable( const std::string& f1 )
  * Create a build path from the executable paths. Also extract the build prefix
  * and BSP names.
  */
-static void createBuildPath(Executables& executablesToAnalyze,
-std::string& buildPath,
-std::string& buildPrefix,
-std::string& buildBSP)
+static void createBuildPath(
+  Executables& executablesToAnalyze,
+  std::string& buildPath,
+  std::string& buildPrefix,
+  std::string& buildBSP
+)
 {
-  for (const auto& exe : executablesToAnalyze) {
+  for ( const auto& exe : executablesToAnalyze ) {
 rld::strings eparts;
-rld::split(eparts, rld::path::path_abs(exe->getFileName()), 
RLD_PATH_SEPARATOR);
+rld::split(
+  eparts,
+  rld::path::path_abs( exe->getFileName() ),
+  RLD_PATH_SEPARATOR
+);
 std::string fail; // empty means all is OK else an error string
-for (rld::path::paths::reverse_iterator pri = eparts.rbegin();
- pri != eparts.rend();
- ++pri) {
-  if (*pri == "testsuites") {
+for (
+  rld::path::paths::reverse_iterator pri = eparts.rbegin();
+  pri != eparts.rend();
+  ++pri
+) {
+  if ( *pri == "testsuites" ) {
 ++pri;
-if (pri == eparts.rend()) {
+if ( pri == eparts.rend() ) {
   fail = "invalid executable path, no BSP";
   break;
 }
-if (buildBSP.empty()) {
+
+if ( buildBSP.empty() ) {
   buildBSP = *pri;
 } else {
-  if (buildBSP != *pri) {
+  if ( buildBSP != *pri ) {
 fail = "executable BSP does not match: " + buildBSP;
 break;
   }
 }
+
 ++pri;
-if (pri == eparts.rend() || *pri != "c") {
+if ( pri == eparts.rend() || *pri != "c" ) {
   fail = "invalid executable path, no 'c'";
   break;
 }
+
 ++pri;
-if (pri == eparts.rend()) {
+if ( pri == eparts.rend() ) {
   fail = "invalid executable path, no arch prefix";
   break;
 }
-if (buildPrefix.empty()) {
+
+if ( buildPrefix.empty() ) {
   buildPrefix = *pri;
 } else {
-  if (buildPrefix != *pri) {
+  if ( buildPrefix != *pri ) {
 fail = "executable build prefix does not match: " + buildPrefix;
 break;
   }
 }
+
 ++pri;
-if (pri == eparts.rend()) {
+if ( pri == eparts.rend() ) {
   fail = "invalid executable path, no build top";
   break;
 }
+
 //
 // The remaining parts of the path is the build path. Iterator over 
them
 // and collect into a new paths variable to join to make a path.
 //
 rld::path::paths bparts;
-for (; pri != eparts.rend(); ++pri)
+for ( ; pri != eparts.rend(); ++pri )
   bparts.insert(bparts.begin(), *pri);
+
 std::string thisBuildPath;
-rld::path::path_join(thisBuildPath, bparts, thisBuildPath);
-if (buildPath.empty()) {
+rld::path::path_join( thisBuildPath, bparts, thisBuildPath );
+if ( buildPath.empty() ) {
   buildPath = thisBuildPath;
 } else {
-  if (buildPath != thisBuildPath) {
+  if ( buildPath != thisBuildPath ) {
 fail = "executable build path does not match: " + buildPath;
   }
 }
+
 break;
   }
 }
-if (!fail.empty()) {
+
+if ( !fail.empty() ) {
   throw rld::error( fail, "createBuildPath" );
 }
   }
@@ -140,10 +159,10 @@ static void createBuildPath(Executables& 
executablesToAnalyze,
 /*
  *  Print program usage message
  */
-void usage(const std::string& progname)
+void usage( const std::string& progname )
 {
-  std::cerr <<"Usage: " << progname
-<<" [-v] -T TARGET -f FORMAT [-E 

[PATCH rtems-tools v2 05/10] CoverageWriterRTEMS.cc: Fix formatting

2021-09-10 Thread Ryan Long
---
 tester/covoar/CoverageWriterRTEMS.cc | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/tester/covoar/CoverageWriterRTEMS.cc 
b/tester/covoar/CoverageWriterRTEMS.cc
index fc8a241..a451999 100644
--- a/tester/covoar/CoverageWriterRTEMS.cc
+++ b/tester/covoar/CoverageWriterRTEMS.cc
@@ -30,9 +30,9 @@ namespace Coverage {
 
   void CoverageWriterRTEMS::writeFile(
 const std::string& file,
-CoverageMapBase*  coverage,
-uint32_t  lowAddress,
-uint32_t  highAddress
+CoverageMapBase*   coverage,
+uint32_t   lowAddress,
+uint32_t   highAddress
   )
   {
 std::ofstream   coverageFile;
@@ -52,9 +52,9 @@ namespace Coverage {
 }
 
 /* clear out the header and fill it in */
-memset( , 0, sizeof(header) );
+memset( , 0, sizeof( header ) );
 header.ver   = 0x1;
-header.header_length = sizeof(header);
+header.header_length = sizeof( header );
 header.start = lowAddress;
 header.end   = highAddress;
 strcpy( header.desc, "RTEMS Coverage Data" );
@@ -68,8 +68,8 @@ namespace Coverage {
   throw rld::error( what, "CoverageWriterRTEMS::writeFile" );
 }
 
-for ( a=lowAddress ; a < highAddress ; a++ ) {
-  cover  = ((coverage->wasExecuted( a )) ? 0x01 : 0);
+for ( a = lowAddress; a < highAddress; a++ ) {
+  cover  = ( ( coverage->wasExecuted( a ) ) ? 0x01 : 0 );
 
   bytes_before = coverageFile.tellp();
 
@@ -78,9 +78,9 @@ namespace Coverage {
 std::cerr << "CoverageWriterRTEMS::writeFile - write to "
   << file
   << " at address 0x%"
-  << std::hex << std::setfill('0')
-  << std::setw(8) << a
-  << std::setfill(' ') << std::dec
+  << std::hex << std::setfill( '0' )
+  << std::setw( 8 ) << a
+  << std::setfill( ' ' ) << std::dec
   << " failed"
   << std::endl;
   }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v2 08/10] CoverageWriterSkyeye.h: Fix formatting

2021-09-10 Thread Ryan Long
---
 tester/covoar/CoverageWriterSkyeye.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tester/covoar/CoverageWriterSkyeye.h 
b/tester/covoar/CoverageWriterSkyeye.h
index 8f11959..5ef6432 100644
--- a/tester/covoar/CoverageWriterSkyeye.h
+++ b/tester/covoar/CoverageWriterSkyeye.h
@@ -36,9 +36,9 @@ namespace Coverage {
 /* Inherit documentation from base class. */
 void writeFile(
   const std::string& file,
-  CoverageMapBase*  coverage,
-  uint32_t  lowAddress,
-  uint32_t  highAddress
+  CoverageMapBase*   coverage,
+  uint32_t   lowAddress,
+  uint32_t   highAddress
 );
   };
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v2 09/10] CoverageWriterTSIM.cc: Fix formatting

2021-09-10 Thread Ryan Long
---
 tester/covoar/CoverageWriterTSIM.cc | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/tester/covoar/CoverageWriterTSIM.cc 
b/tester/covoar/CoverageWriterTSIM.cc
index 9ec12e4..ed9da96 100644
--- a/tester/covoar/CoverageWriterTSIM.cc
+++ b/tester/covoar/CoverageWriterTSIM.cc
@@ -29,15 +29,15 @@ namespace Coverage {
 
   void CoverageWriterTSIM::writeFile(
 const std::string& file,
-CoverageMapBase*  coverage,
-uint32_t  lowAddress,
-uint32_t  highAddress
+CoverageMapBase*   coverage,
+uint32_t   lowAddress,
+uint32_t   highAddress
   )
   {
-uint32_t a;
-int  cover;
+uint32_t  a;
+int   cover;
 std::ofstream coverageFile;
-int  i;
+int   i;
 
 /*
  *  read the file and update the coverage map passed in
@@ -54,23 +54,23 @@ namespace Coverage {
   if ( coverageFile.fail() ) {
 break;
   }
+
   for ( i = 0; i < 0x80; i += 4 ) {
-cover = ((coverage->wasExecuted( a + i )) ? 1 : 0);
+cover = ( ( coverage->wasExecuted( a + i ) ) ? 1 : 0 );
 coverageFile << cover << " ";
 
 if ( coverageFile.fail() ) {
   std::ostringstream what;
   what << "write to " << file
<< " at address 0x"
-   << std::hex << std::setfill('0')
-   << std::setw(8) << a
-   << std::setfill(' ') << std::dec
+   << std::hex << std::setfill( '0' )
+   << std::setw( 8 ) << a
+   << std::setfill( ' ' ) << std::dec
<< "failed";
   throw rld::error( what, "CoverageWriterTSIM::writeFile" );
 }
   }
   coverageFile << std::endl;
 }
-
   }
 }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v2 10/10] CoverageWriterTSIM.h: Fix formatting

2021-09-10 Thread Ryan Long
---
 tester/covoar/CoverageWriterTSIM.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tester/covoar/CoverageWriterTSIM.h 
b/tester/covoar/CoverageWriterTSIM.h
index 5ae57f8..9325a6a 100644
--- a/tester/covoar/CoverageWriterTSIM.h
+++ b/tester/covoar/CoverageWriterTSIM.h
@@ -36,9 +36,9 @@ namespace Coverage {
 /* Inherit documentation from base class. */
 void writeFile(
   const std::string& file,
-  CoverageMapBase*  coverage,
-  uint32_t  lowAddress,
-  uint32_t  highAddress
+  CoverageMapBase*   coverage,
+  uint32_t   lowAddress,
+  uint32_t   highAddress
 );
   };
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v2 01/10] CoverageWriter: Convert to C++

2021-09-10 Thread Ryan Long
---
 tester/covoar/CoverageWriterBase.h|  4 +++-
 tester/covoar/CoverageWriterRTEMS.cc  | 26 +--
 tester/covoar/CoverageWriterRTEMS.h   |  4 +++-
 tester/covoar/CoverageWriterSkyeye.cc | 39 +++
 tester/covoar/CoverageWriterSkyeye.h  |  4 +++-
 tester/covoar/CoverageWriterTSIM.cc   | 23 ++---
 tester/covoar/CoverageWriterTSIM.h|  4 +++-
 7 files changed, 59 insertions(+), 45 deletions(-)

diff --git a/tester/covoar/CoverageWriterBase.h 
b/tester/covoar/CoverageWriterBase.h
index e43a45b..fca501a 100644
--- a/tester/covoar/CoverageWriterBase.h
+++ b/tester/covoar/CoverageWriterBase.h
@@ -9,6 +9,8 @@
 
 #include 
 
+#include 
+
 #include "CoverageMapBase.h"
 
 namespace Coverage {
@@ -46,7 +48,7 @@ namespace Coverage {
  *  @return Returns TRUE if the method succeeded and FALSE if it failed.
  */
 virtual void writeFile(
-  const char* const file,
+  const std::string& file,
   CoverageMapBase*  coverage,
   uint32_t  lowAddress,
   uint32_t  highAddress
diff --git a/tester/covoar/CoverageWriterRTEMS.cc 
b/tester/covoar/CoverageWriterRTEMS.cc
index 48e8fd1..fc8a241 100644
--- a/tester/covoar/CoverageWriterRTEMS.cc
+++ b/tester/covoar/CoverageWriterRTEMS.cc
@@ -10,6 +10,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 #include 
@@ -28,23 +29,23 @@ namespace Coverage {
   }
 
   void CoverageWriterRTEMS::writeFile(
-const char* const file,
+const std::string& file,
 CoverageMapBase*  coverage,
 uint32_t  lowAddress,
 uint32_t  highAddress
   )
   {
-FILE*   coverageFile;
+std::ofstream   coverageFile;
 uint32_ta;
-int status;
 uint8_t cover;
 rtems_coverage_map_header_t header;
+std::ofstream::pos_type bytes_before;
 
 /*
  *  read the file and update the coverage map passed in
  */
-coverageFile = ::fopen( file, "w" );
-if ( !coverageFile ) {
+coverageFile.open( file );
+if ( !coverageFile.is_open() ) {
   std::ostringstream what;
   what << "Unable to open " << file;
   throw rld::error( what, "CoverageWriterRTEMS::writeFile" );
@@ -58,9 +59,10 @@ namespace Coverage {
 header.end   = highAddress;
 strcpy( header.desc, "RTEMS Coverage Data" );
 
-status = ::fwrite(, 1, sizeof(header), coverageFile);
-if (status != sizeof(header)) {
-  ::fclose( coverageFile );
+bytes_before = coverageFile.tellp();
+
+coverageFile.write( (char *) , sizeof( header ) );
+if ( coverageFile.tellp() - bytes_before != sizeof( header ) ) {
   std::ostringstream what;
   what << "Unable to write header to " << file;
   throw rld::error( what, "CoverageWriterRTEMS::writeFile" );
@@ -68,8 +70,11 @@ namespace Coverage {
 
 for ( a=lowAddress ; a < highAddress ; a++ ) {
   cover  = ((coverage->wasExecuted( a )) ? 0x01 : 0);
-  status = fwrite(, 1, sizeof(cover), coverageFile);
-  if (status != sizeof(cover)) {
+
+  bytes_before = coverageFile.tellp();
+
+  coverageFile.write( (char *) , sizeof( cover ) );
+  if ( coverageFile.tellp() - bytes_before != sizeof( cover ) ) {
 std::cerr << "CoverageWriterRTEMS::writeFile - write to "
   << file
   << " at address 0x%"
@@ -81,6 +86,5 @@ namespace Coverage {
   }
 }
 
-::fclose( coverageFile );
   }
 }
diff --git a/tester/covoar/CoverageWriterRTEMS.h 
b/tester/covoar/CoverageWriterRTEMS.h
index b66d2fa..c760936 100644
--- a/tester/covoar/CoverageWriterRTEMS.h
+++ b/tester/covoar/CoverageWriterRTEMS.h
@@ -7,6 +7,8 @@
 #ifndef __COVERAGE_WRITER_RTEMS_H__
 #define __COVERAGE_WRITER_RTEMS_H__
 
+#include 
+
 #include "CoverageMapBase.h"
 #include "CoverageWriterBase.h"
 
@@ -33,7 +35,7 @@ namespace Coverage {
 
 /* Inherit documentation from base class. */
 void writeFile(
-  const char* const file,
+  const std::string& file,
   CoverageMapBase*  coverage,
   uint32_t  lowAddress,
   uint32_t  highAddress
diff --git a/tester/covoar/CoverageWriterSkyeye.cc 
b/tester/covoar/CoverageWriterSkyeye.cc
index 7f78644..fcc7052 100644
--- a/tester/covoar/CoverageWriterSkyeye.cc
+++ b/tester/covoar/CoverageWriterSkyeye.cc
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 #include 
@@ -30,23 +31,23 @@ namespace Coverage {
   }
 
   void CoverageWriterSkyeye::writeFile(
-const char* const file,
-CoverageMapBase*  coverage,
-uint32_t  lowAddress,
-uint32_t  highAddress
+const std::string&  file,
+CoverageMapBase*coverage,
+uint32_tlowAddress,
+uint32_thighAddress
   )
   {
-uint32_t  a;
-uint8_t   cover;
-FILE* coverageFile;
-prof_header_t header;
-int   status;
+

[PATCH rtems-tools v2 00/10] Convert and reformat pt. 2

2021-09-10 Thread Ryan Long
Hi,

For these patches I

- Changed the data type of bytes_before so that it builds with clang
- Replaced instances of "\n" with std::endl
- Changed .c_str() argument to just a string

Thanks,
Ryan

Ryan Long (10):
  CoverageWriter: Convert to C++
  covoar.cc: Convert to C++
  CoverageWriterBase.h: Fix formatting
  covoar.cc: Fix formatting
  CoverageWriterRTEMS.cc: Fix formatting
  CoverageWriterRTEMS.h: Fix formatting
  CoverageWriterSkyeye.cc: Fix formatting
  CoverageWriterSkyeye.h: Fix formatting
  CoverageWriterTSIM.cc: Fix formatting
  CoverageWriterTSIM.h: Fix formatting

 tester/covoar/CoverageWriterBase.h|  10 +-
 tester/covoar/CoverageWriterRTEMS.cc  |  46 ++---
 tester/covoar/CoverageWriterRTEMS.h   |  10 +-
 tester/covoar/CoverageWriterSkyeye.cc |  49 ++---
 tester/covoar/CoverageWriterSkyeye.h  |  10 +-
 tester/covoar/CoverageWriterTSIM.cc   |  45 +++--
 tester/covoar/CoverageWriterTSIM.h|  10 +-
 tester/covoar/covoar.cc   | 334 ++
 8 files changed, 279 insertions(+), 235 deletions(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v2 02/10] covoar.cc: Convert to C++

2021-09-10 Thread Ryan Long
Got rid of C-strings, changed FILE pointer to ifstream.
---
 tester/covoar/covoar.cc | 50 +++--
 1 file changed, 23 insertions(+), 27 deletions(-)

diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc
index f9d4814..710294b 100644
--- a/tester/covoar/covoar.cc
+++ b/tester/covoar/covoar.cc
@@ -45,11 +45,11 @@ typedef std::list CoverageNames;
 typedef std::list Executables;
 typedef std::string option_error;
 
-bool FileIsReadable( const char *f1 )
+bool FileIsReadable( const std::string& f1 )
 {
   struct STAT buf1;
 
-  if (STAT( f1,  ) == -1)
+  if (STAT( f1.c_str(),  ) == -1)
 return false;
 
   if (buf1.st_size == 0)
@@ -177,17 +177,14 @@ int covoar(
   std::string   coverageExtension = "cov";
   Coverage::CoverageFormats_t   coverageFormat = 
Coverage::COVERAGE_FORMAT_QEMU;
   Coverage::CoverageReaderBase* coverageReader = NULL;
-  char* executable = NULL;
-  const char*   explanations = NULL;
-  const char*   gcnosFileName = NULL;
-  char  gcnoFileName[FILE_NAME_LENGTH];
-  char  gcdaFileName[FILE_NAME_LENGTH];
-  char  gcovBashCommand[256];
+  std::string   explanations;
+  std::string   gcnosFileName;
+  std::string   gcnoFileName;
   std::string   target;
-  const char*   format = "QEMU";
-  FILE* gcnosFile = NULL;
+  std::string   format = "QEMU";
+  std::ifstream gcnosFile;
   Gcov::GcovData*   gcovFile;
-  const char*   singleExecutable = NULL;
+  std::string   singleExecutable;
   rld::process::tempfileobjdumpFile( ".dmp" );
   rld::process::tempfileerr( ".err" );
   rld::process::tempfilesyms( ".syms" );
@@ -203,7 +200,6 @@ int covoar(
   std::string   outputDirectory = ".";
   Coverage::DesiredSymbols  symbolsToAnalyze;
   bool  branchInfoAvailable = false;
-  //Target::TargetBase*   targetInfo;
 
   //
   // Process command line options.
@@ -243,7 +239,7 @@ int covoar(
   /*
* Has path to explanations.txt been specified.
*/
-  if ( !explanations )
+  if ( explanations.empty() )
 throw option_error( "explanations -E" );
 
   /*
@@ -272,7 +268,7 @@ int covoar(
   }
 
   if (verbose) {
-if (singleExecutable) {
+if (!singleExecutable.empty()) {
   std::cerr << "Processing a single executable and multiple coverage files"
 << std::endl;
 } else {
@@ -287,7 +283,7 @@ int covoar(
 for (const auto& cname : coverageFileNames) {
   std::cerr << "Coverage file " << cname
 << " for executable: " << (*eitr)->getFileName() << std::endl;
-  if (!singleExecutable)
+  if (singleExecutable.empty())
 eitr++;
 }
   }
@@ -309,7 +305,7 @@ int covoar(
 
   // If a single executable was specified, process the remaining
   // arguments as coverage file names.
-  if (singleExecutable) {
+  if (!singleExecutable.empty()) {
 
 // Ensure that the executable is readable.
 if (!FileIsReadable( singleExecutable )) {
@@ -332,14 +328,14 @@ int covoar(
   if (!coverageFileNames.empty()) {
 if ( !dynamicLibrary.empty() ) {
   executableInfo = new Coverage::ExecutableInfo(
-singleExecutable,
+singleExecutable.c_str(),
 dynamicLibrary,
 verbose,
 symbolsToAnalyze
   );
 } else {
   executableInfo = new Coverage::ExecutableInfo(
-singleExecutable,
+singleExecutable.c_str(),
 "",
 verbose,
 symbolsToAnalyze
@@ -393,8 +389,8 @@ int covoar(
   << " symbols" << std::endl;
 
   // Create explanations.
-  if ( explanations )
-allExplanations.load( explanations );
+  if ( !explanations.empty() )
+allExplanations.load( explanations.c_str() );
 
   // Create coverage map reader.
   coverageFormat = Coverage::CoverageFormatToEnum(format);
@@ -441,7 +437,7 @@ int covoar(
 // DEBUG Print ExecutableInfo content
 //exe->dumpExecutableInfo();
 
-if (!singleExecutable) {
+if (singleExecutable.empty()) {
   eitr++;
 }
   }
@@ -455,18 +451,18 @@ int covoar(
   //
   // Generate Gcov reports
   //
-  if (gcnosFileName) {
+  if (!gcnosFileName.empty()) {
 if (verbose)
   std::cerr << "Generating Gcov reports..." << std::endl;
 
-gcnosFile = fopen ( gcnosFileName , "r" );
+gcnosFile.open( gcnosFileName );
 
 if ( !gcnosFile )
   std::cerr << "Unable to open " << gcnosFileName << std::endl;
 else {
-  while ( fscanf( gcnosFile, "%s", inputBuffer ) != EOF) {
+  while ( gcnosFile >> inputBuffer ) {
 gcovFile = new Gcov::GcovData( symbolsToAnalyze );
-

[PATCH RSB v1 0/2] Update newlib for ILP32

2021-09-13 Thread Ryan Long
Hi,

These patches add some of the code that we are waiting for newlib to
pull.

Thanks,
Ryan

Ryan Long (2):
  rtems-gcc-10-newlib-head.cfg: Add newlib patch
  rtems-gcc-head-newlib-head.cfg: Add newlib patch

 rtems/config/tools/rtems-gcc-10-newlib-head.cfg   | 3 +++
 rtems/config/tools/rtems-gcc-head-newlib-head.cfg | 3 +++
 2 files changed, 6 insertions(+)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH RSB v1 1/2] rtems-gcc-10-newlib-head.cfg: Add newlib patch

2021-09-13 Thread Ryan Long
Adds patch to add sanitation to the padding of bits and size_t types for
AArch64 tools builds with newlib. These changes have been made in ARM, but
newlib has yet to pull them. This can be removed once newlib has pulled
the code.

Updates #4510
---
 rtems/config/tools/rtems-gcc-10-newlib-head.cfg | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg 
b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
index 69c4fb5..c54ac52 100644
--- a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
+++ b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
@@ -13,6 +13,9 @@
 %patch add gcc -p1 
https://devel.rtems.org/raw-attachment/ticket/4215/0001-nios2-Remove-custom-instruction-warnings.patch
 %hash sha512 0001-nios2-Remove-custom-instruction-warnings.patch 
afd8a5e6bdcc5b75d5fbbf558bdf56ccac400521a6eec9d88cc95f6be67c481f2dbf8faa0f6ddc1e4ac7c56a84938714d80e46e9cf80ec4b8fcd739986449881
 
++%patch add newlib -p1 
https://devel.rtems.org/raw-attachment/ticket/4510/0001-aarch64-Add-ILP32-ABI-support-in-assembly.patch
++%hash sha512 0001-aarch64-Add-ILP32-ABI-support-in-assembly.patch 
BHRMimj6ztKPHQFxypI8RwPmno96B56eVQGx5dtCtcOb+qICMrQC1fa0jP3JrR8RGJI4y61RoYvpnj6EbTmRKA==
+
 %define newlib_version 4f81149
 %define newlib_external 1
 %define newlib_expand_name sourceware-mirror-newlib-cygwin-%{newlib_version}
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH RSB v1 2/2] rtems-gcc-head-newlib-head.cfg: Add newlib patch

2021-09-13 Thread Ryan Long
Adds patch to add sanitation to the padding of bits and size_t types for
AArch64 tools builds with newlib. These changes have been made in ARM, but
newlib has yet to pull them. This can be removed once newlib has pulled
the code.

Updates #4510
---
 rtems/config/tools/rtems-gcc-head-newlib-head.cfg | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rtems/config/tools/rtems-gcc-head-newlib-head.cfg 
b/rtems/config/tools/rtems-gcc-head-newlib-head.cfg
index 4939ca5..fdb04d2 100644
--- a/rtems/config/tools/rtems-gcc-head-newlib-head.cfg
+++ b/rtems/config/tools/rtems-gcc-head-newlib-head.cfg
@@ -13,6 +13,9 @@
 %source set newlib --rsb-file=newlib-%{newlib_version}.tar.gz 
https://codeload.github.com/RTEMS/sourceware-mirror-newlib-cygwin/tar.gz/%{newlib_version}
 %hash sha512 newlib-%{newlib_version}.tar.gz 
9ded46b3077508ef05bbb4bf424777a0baa5aab9c7c0c902fb5529bb73b5b5034c35282e2dbf270cbcd44d84940a20ee270e329db4e4b501046978c18f78a11c
 
+%patch add newlib -p1 
https://devel.rtems.org/raw-attachment/ticket/4510/0001-aarch64-Add-ILP32-ABI-support-in-assembly.patch
+%hash sha512 0001-aarch64-Add-ILP32-ABI-support-in-assembly.patch 
BHRMimj6ztKPHQFxypI8RwPmno96B56eVQGx5dtCtcOb+qICMrQC1fa0jP3JrR8RGJI4y61RoYvpnj6EbTmRKA==
+
 %define with_threads 1
 %define with_plugin 0
 %define with_iconv 1
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools] check.py: Fix incorrect use of os.linesep

2021-09-14 Thread Ryan Long
Replaced a couple of calls to os.linesep() with os.linesep because
os.linesep() does not exist.
---
 tester/rt/check.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tester/rt/check.py b/tester/rt/check.py
index 95fa47e..c01c25d 100755
--- a/tester/rt/check.py
+++ b/tester/rt/check.py
@@ -966,13 +966,13 @@ class builder:
 def _create_config(self, job, commands):
 filename = 'config-%s-%s-%s.ini' % (job.arch, job.bsp, job.build)
 cfg_file = open(path.join(self.rtems, filename),'w+')
-cfg_file.write('[%s/%s]' + os.linsep() % (job.arch, job.bsp))
+cfg_file.write('[%s/%s]' % (job.arch, job.bsp) + os.linesep)
 new_cfg_cmds = []
 for option in commands['configure'].split():
 if 'waf' in option or '--' in option or 'configure' in option:
 new_cfg_cmds += [option]
 else:
-cfg_file.write(option + os.linesep())
+cfg_file.write(option + os.linesep)
 commands['configure'] = ' '.join(new_cfg_cmds)
 cfg_file.close()
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


RE: [PATCH RSB v2 2/2] rtems-gcc-head-newlib-head.cfg: Add newlib patch

2021-09-07 Thread Ryan Long
Kinsey got the fix merged upstream from newlib, so now we just have to wait 
till newlib pulls those changes.

-Original Message-
From: Gedare Bloom  
Sent: Tuesday, September 7, 2021 1:09 PM
To: Ryan Long 
Cc: devel@rtems.org
Subject: Re: [PATCH RSB v2 2/2] rtems-gcc-head-newlib-head.cfg: Add newlib patch

Has this issue been raised with newlib? I didn't see anything on their ml. The 
temporary workaround is fine with me.

On Fri, Sep 3, 2021 at 11:17 AM Ryan Long  wrote:
>
> Adds patch to add the -DPREFER_SIZE_OVER_SPEED flag to AArch64 tools 
> builds with newlib. This forces the generation of AArch64 assembly 
> from C sources instead of using the hand-optimized code in newlib 
> since it does not support ILP32. This can be removed when it is fixed 
> upstream.
>
> Updates #4510
> ---
>  rtems/config/tools/rtems-gcc-head-newlib-head.cfg | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/rtems/config/tools/rtems-gcc-head-newlib-head.cfg 
> b/rtems/config/tools/rtems-gcc-head-newlib-head.cfg
> index 4939ca5..c17895b 100644
> --- a/rtems/config/tools/rtems-gcc-head-newlib-head.cfg
> +++ b/rtems/config/tools/rtems-gcc-head-newlib-head.cfg
> @@ -12,6 +12,9 @@
>  %define newlib_expand_name 
> sourceware-mirror-newlib-cygwin-%{newlib_version}
>  %source set newlib --rsb-file=newlib-%{newlib_version}.tar.gz 
> https://codeload.github.com/RTEMS/sourceware-mirror-newlib-cygwin/tar.
> gz/%{newlib_version}  %hash sha512 newlib-%{newlib_version}.tar.gz 
> 9ded46b3077508ef05bbb4bf424777a0baa5aab9c7c0c902fb5529bb73b5b5034c3528
> 2e2dbf270cbcd44d84940a20ee270e329db4e4b501046978c18f78a11c
> +%
> +%patch add newlib -p1 
> +https://devel.rtems.org/raw-attachment/ticket/4510/0001-configure.hos
> +t-Add-DPREFER_SIZE_OVER_SPEED.patch
> +%hash sha512 0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch 
> +rRg7bJoWjR11FQXmSHPxF8EfsFmBnTQcXXFWGZhbKFwyTvJ8EXfGMACI33u+OuvX+gNAN
> +MOJLyv27FcyTJseKg==
>
>  %define with_threads 1
>  %define with_plugin 0
> --
> 1.8.3.1
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


<    1   2   3   4   5   6   7   >