rtems-bsps: add ability to print architecture/bsps list

2020-09-28 Thread Ryan Long
Hi,

The attached patch adds the ability to print the set of bsps in the form of 
architecture/bsp. This is useful for feeding into other programs.

Thanks,
Ryan


0001-rtems-bsps-add-ability-to-print-architecture-bsp-lis.patch
Description: 0001-rtems-bsps-add-ability-to-print-architecture-bsp-lis.patch
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Oddity with address recorded for gcc instrumentation on ARM

2020-12-18 Thread Ryan Long
Hi,

We turned on gcc instrumentation with a test function, and got the following 
records.

Timestamp Channel   CPU   Event type
  Contents TID PrioPID  
  Source
18:00:06.483 017 719 stream_0 0  FUNCTION_ENTRY 
  code=0x104ec7 167837716   0167837716
18:00:06.483 371 019 stream_0 0  FUNCTION_EXIT  
 code=0x104ec7 167837716   0167837716

Notice that the code value ends in "7". The actual address of the function is 
0x104ec6.

Can someone explain this?

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

rtems-record-lttng live support

2021-01-04 Thread Ryan Long
Hi,

Can rtems-record-lttng provide a live feed of traces?

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

Debugging rtems-docs Sphinx issue

2021-02-02 Thread Ryan Long
Hi,

I'm working on https://devel.rtems.org/ticket/4229#ticket .  The following 
command is being issued:

/home/rlong/nta-workspace/nta-docs/sphinx/bin/sphinx-build -b html -D 
extensions=sphinxcontrib.bibtex -C . out contents.rst ->

If I run this with the "->" at the end, I get "bash: syntax error near 
unexpected token `newline'" as the erro message. If I run it without the arrow,
It prints out the usage, and it says "sphinx-build: error: cannot find files 
['contents.rst']".

I tried adding the recommended configuration settings to each of the conf.py 
files as sphinxcontrib-bibtex's documentation recommended, and
I added "master_doc = 'contents'" to each of them as well based on the warning 
message from config.log. Neither had any effect.
Does anyone know how to fix this?

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

RE: Debugging rtems-docs Sphinx issue

2021-02-03 Thread Ryan Long
Gedare,

I applied your patch, but it still isn’t working for me. The error is the same 
in the console output and config.log.
The ./waf configure command that I’m running is

./waf configure --prefix='`pwd`' –pdf

I don’t know if that could be part of the issue.

Thanks,
Ryan

From: Gedare Bloom 
Sent: Wednesday, February 3, 2021 11:28 AM
To: Ryan Long 
Cc: devel@rtems.org
Subject: Re: Debugging rtems-docs Sphinx issue

Hi Ryan,


On Tue, Feb 2, 2021 at 2:53 PM Ryan Long 
mailto:ryan.l...@oarcorp.com>> wrote:
Hi,

I’m working on https://devel.rtems.org/ticket/4229#ticket .  The following 
command is being issued:

/home/rlong/nta-workspace/nta-docs/sphinx/bin/sphinx-build -b html -D 
extensions=sphinxcontrib.bibtex -C . out contents.rst ->

If I run this with the “->” at the end, I get “bash: syntax error near 
unexpected token `newline'” as the erro message. If I run it without the arrow,
It prints out the usage, and it says “sphinx-build: error: cannot find files 
['contents.rst']”.


That -> is not valid bash syntax. I guess that is something out of the waf 
error logging. You can see where these checks are built in common/waf.py

contents.rst appears to be something generated dynamically by that waf.py in 
check_sphinx_extension, so that is not something you can test independently.

I tried adding the recommended configuration settings to each of the conf.py 
files as sphinxcontrib-bibtex’s documentation recommended, and
I added “master_doc = 'contents'” to each of them as well based on the warning 
message from config.log. Neither had any effect.

I think the master_doc thing is unrelated.


Does anyone know how to fix this?


It looks like the important part is actually this:

err:
Extension error:
You must configure the bibtex_bibfiles setting
So our waf.py that checks the sphinxcontrib.bibtex extension does not pass 
through the bibtex_bibfiles setting.

Since that check uses the -C flag, the config file doesn't get read, so 
modifying conf.py will bring no joy. That said, we should include that 
bibtex_bibfiles in our conf.py, so I add that in a separate patch.

You can create a file contents.rst by hand and put in it the same:
.. COMMENT sphinx test

then you can run
$ sphinx-build -b html -D extensions=sphinx.ext.autodoc -C . out contents.rst
for example

Unfortunately, I can't seem to figure out how to pass the bibtex_bibfiles list 
to the command line. Everything I tried ends up parsing it into individual 
characters, e.g.,
$ touch refs.bib
$ sphinx-build -b html -D extensions=sphinxcontrib.bibtex -D 
bibtex_bibfiles=refs.bib -C . out contents.rst

WARNING: could not open bibtex file /mnt/devel/rtems/rtems-docs/build/r.
WARNING: could not open bibtex file /mnt/devel/rtems/rtems-docs/build/e.
WARNING: could not open bibtex file /mnt/devel/rtems/rtems-docs/build/f.
WARNING: could not open bibtex file /mnt/devel/rtems/rtems-docs/build/s.
then it dies because it can't open .

What I could get to work is to create a minimal config file and pass that:
$ echo "bibtex_bibfiles = ['refs.bib']" > conf.py
sphinx-build -b html -D extensions=sphinxcontrib.bibtex -c . . out contents.rst

So I made the check rule dynamically create refs.bib and conf.py within the 
testbuild directory. It might be more elegant to figure out how to pass the 
_list_ that contains refs.bib in the command line -D version, but this seemed 
to work.

I also added the bibtex_bibfiles setting to our common/conf.py file. Please try 
out the patch I just sent.

Thanks,
Gedare

Thanks,
Ryan
___
devel mailing list
devel@rtems.org<mailto:devel@rtems.org>
http://lists.rtems.org/mailman/listinfo/devel
___
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", &cons->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,
 &cons->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 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 = ¤t[i];
-- 
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 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", &cons->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,
 &cons->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 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 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(&priv->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/4] Fix Unchecked return value Coverity errors

2021-02-26 Thread Ryan Long
Hi,

Here are some fixes for a few of the "Unchecked return value" Coverity
errors. Mainly, I just created a variable to store the status code returned 
from function calls and used the _Assert_Unused_variable_equals() macro
to assert that the call was successful. I also added a (void) in front
of the call to fsync() since that was getting flagged as well.

Thanks,
Ryan

Ryan Long (4):
  printertask.c: Fix Unchecked return value (CID #1399710)
  record-client.c: Fix Unchecked return value (CID #1456677)
  getgrent.c: Fix Unchecked return value error (CID #1459004)
  rtems-debugger-threads.c: Fix Unchecked return value error (CID
#1468688)

 cpukit/libcsupport/src/getgrent.c   | 4 +++-
 cpukit/libcsupport/src/printertask.c| 9 ++---
 cpukit/libdebugger/rtems-debugger-threads.c | 5 -
 cpukit/libtrace/record/record-client.c  | 4 +++-
 4 files changed, 16 insertions(+), 6 deletions(-)

-- 
1.8.3.1

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


[PATCH 1/4] printertask.c: Fix Unchecked return value (CID #1399710)

2021-02-26 Thread Ryan Long
CID 1399710: Unchecked return value in printer_task().
CID 1472764: Unchecked return value in rtems_print_printer_task().

Closes #4258
---
 cpukit/libcsupport/src/printertask.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/cpukit/libcsupport/src/printertask.c 
b/cpukit/libcsupport/src/printertask.c
index bae623b..bca90a1 100644
--- a/cpukit/libcsupport/src/printertask.c
+++ b/cpukit/libcsupport/src/printertask.c
@@ -117,6 +117,7 @@ static void printer_task( rtems_task_argument arg )
 {
   rtems_printer_task_context *ctx;
   int fd;
+  rtems_status_code   sc;
 
   ctx = (rtems_printer_task_context *) arg;
   fd = ctx->fd;
@@ -141,8 +142,9 @@ static void printer_task( rtems_task_argument arg )
   printer_task_append_buffer( ctx, &ctx->free_buffers, buffer );
   break;
 case ACTION_DRAIN:
-  fsync(fd);
-  rtems_event_transient_send( buffer->action_data.task );
+  (void)fsync(fd);
+  sc = rtems_event_transient_send( buffer->action_data.task );
+  _Assert_Unused_variable_equals(sc, RTEMS_SUCCESSFUL);
   break;
   }
 }
@@ -185,7 +187,8 @@ int rtems_print_printer_task(
   printer->context = ctx;
   printer->printer = printer_task_printer;
 
-  rtems_task_start( ctx->task, printer_task, (rtems_task_argument) ctx );
+  sc = rtems_task_start( ctx->task, printer_task, (rtems_task_argument) ctx );
+  _Assert_Unused_variable_equals(sc, RTEMS_SUCCESSFUL);
 
   return 0;
 }
-- 
1.8.3.1

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


[PATCH 2/4] record-client.c: Fix Unchecked return value (CID #1456677)

2021-02-26 Thread Ryan Long
CID 1456677: Unchecked return value in resolve_hold_back().

Closes #4260
---
 cpukit/libtrace/record/record-client.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cpukit/libtrace/record/record-client.c 
b/cpukit/libtrace/record/record-client.c
index 5a68115..975e3a7 100644
--- a/cpukit/libtrace/record/record-client.c
+++ b/cpukit/libtrace/record/record-client.c
@@ -124,6 +124,7 @@ static void resolve_hold_back(
 uint32_t last;
 uint32_t delta;
 uint64_t uptime;
+rtems_record_client_status status;
 
 last_head = per_cpu->head[ per_cpu->tail_head_index ];
 last_tail = per_cpu->tail[ per_cpu->tail_head_index ];
@@ -192,7 +193,8 @@ static void resolve_hold_back(
   const rtems_record_item_64 *item;
 
   item = &per_cpu->items[ index ];
-  visit( ctx, item->event, item->data );
+  status = visit( ctx, item->event, item->data );
+  _Assert_Unused_variable_equals(status, RTEMS_RECORD_CLIENT_SUCCESS);
 }
   }
 }
-- 
1.8.3.1

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


[PATCH 3/4] getgrent.c: Fix Unchecked return value error (CID #1459004)

2021-02-26 Thread Ryan Long
CID 1459004: Unchecked return value in endgrent().

Closes #4261
---
 cpukit/libcsupport/src/getgrent.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cpukit/libcsupport/src/getgrent.c 
b/cpukit/libcsupport/src/getgrent.c
index b358cb9..534e04c 100644
--- a/cpukit/libcsupport/src/getgrent.c
+++ b/cpukit/libcsupport/src/getgrent.c
@@ -95,6 +95,7 @@ void setgrent(void)
 void endgrent(void)
 {
   grp_context *ctx = grp_get_context();
+  int  sc;
 
   if (ctx == NULL)
 return;
@@ -104,5 +105,6 @@ void endgrent(void)
   }
 
   free(ctx);
-  pthread_setspecific(grp_key, NULL);
+  sc = pthread_setspecific(grp_key, NULL);
+  _Assert_Unused_variable_equals(sc,0);
 }
-- 
1.8.3.1

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


[PATCH 4/4] rtems-debugger-threads.c: Fix Unchecked return value error (CID #1468688)

2021-02-26 Thread Ryan Long
CID 1468688: Unchecked return value in snapshot_thread().

Closes #4262
---
 cpukit/libdebugger/rtems-debugger-threads.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cpukit/libdebugger/rtems-debugger-threads.c 
b/cpukit/libdebugger/rtems-debugger-threads.c
index 5b96e5f..ee8d654 100644
--- a/cpukit/libdebugger/rtems-debugger-threads.c
+++ b/cpukit/libdebugger/rtems-debugger-threads.c
@@ -170,6 +170,7 @@ snapshot_thread(rtems_tcb* tcb, void* arg)
   charname[RTEMS_DEBUGGER_THREAD_NAME_SIZE];
   boolexclude = false;
   size_t  i;
+  int sc;
 
   /*
* The only time the threads pointer is NULL is a realloc error so we stop
@@ -272,7 +273,9 @@ snapshot_thread(rtems_tcb* tcb, void* arg)
 /*
  * Read the target registers into the thread register array.
  */
-rtems_debugger_target_read_regs(thread);
+sc = rtems_debugger_target_read_regs(thread);
+_Assert_Unused_variable_equals(sc, 0);
+
 
 if (rtems_debugger_server_flag(RTEMS_DEBUGGER_FLAG_VERBOSE))
   rtems_debugger_printf("rtems-db: sys: thd: %08" PRIx32 ": signal: %d\n",
-- 
1.8.3.1

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


[PATCH v2 1/4] printertask.c: Fix Unchecked return value (CID #1399710)

2021-02-26 Thread Ryan Long
CID 1399710: Unchecked return value in printer_task().
CID 1472764: Unchecked return value in rtems_print_printer_task().

Closes #4258
---
 cpukit/libcsupport/src/printertask.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/cpukit/libcsupport/src/printertask.c 
b/cpukit/libcsupport/src/printertask.c
index bae623b..31d569f 100644
--- a/cpukit/libcsupport/src/printertask.c
+++ b/cpukit/libcsupport/src/printertask.c
@@ -117,6 +117,8 @@ static void printer_task( rtems_task_argument arg )
 {
   rtems_printer_task_context *ctx;
   int fd;
+  int err;
+  rtems_status_code   sc;
 
   ctx = (rtems_printer_task_context *) arg;
   fd = ctx->fd;
@@ -141,8 +143,10 @@ static void printer_task( rtems_task_argument arg )
   printer_task_append_buffer( ctx, &ctx->free_buffers, buffer );
   break;
 case ACTION_DRAIN:
-  fsync(fd);
-  rtems_event_transient_send( buffer->action_data.task );
+  err = fsync(fd);
+  _Assert_Unused_variable_equals(err, 0);
+  sc = rtems_event_transient_send( buffer->action_data.task );
+  _Assert_Unused_variable_equals(sc, RTEMS_SUCCESSFUL);
   break;
   }
 }
@@ -185,7 +189,8 @@ int rtems_print_printer_task(
   printer->context = ctx;
   printer->printer = printer_task_printer;
 
-  rtems_task_start( ctx->task, printer_task, (rtems_task_argument) ctx );
+  sc = rtems_task_start( ctx->task, printer_task, (rtems_task_argument) ctx );
+  _Assert_Unused_variable_equals(sc, RTEMS_SUCCESSFUL);
 
   return 0;
 }
-- 
1.8.3.1

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


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

2021-02-26 Thread Ryan Long
Hi,

Here's the patches with the changes.

Thanks,
Ryan

Ryan Long (4):
  printertask.c: Fix Unchecked return value (CID #1399710)
  record-client.c: Fix Unchecked return value (CID #1456677)
  getgrent.c: Fix Unchecked return value error (CID #1459004)
  rtems-debugger-threads.c: Fix Unchecked return value error (CID
#1468688)

 cpukit/libcsupport/src/getgrent.c   |  4 +++-
 cpukit/libcsupport/src/printertask.c| 11 ---
 cpukit/libdebugger/rtems-debugger-threads.c |  4 +++-
 cpukit/libtrace/record/record-client.c  |  4 +++-
 4 files changed, 17 insertions(+), 6 deletions(-)

-- 
1.8.3.1

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


[PATCH v2 2/4] record-client.c: Fix Unchecked return value (CID #1456677)

2021-02-26 Thread Ryan Long
CID 1456677: Unchecked return value in resolve_hold_back().

Closes #4260
---
 cpukit/libtrace/record/record-client.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cpukit/libtrace/record/record-client.c 
b/cpukit/libtrace/record/record-client.c
index 5a68115..975e3a7 100644
--- a/cpukit/libtrace/record/record-client.c
+++ b/cpukit/libtrace/record/record-client.c
@@ -124,6 +124,7 @@ static void resolve_hold_back(
 uint32_t last;
 uint32_t delta;
 uint64_t uptime;
+rtems_record_client_status status;
 
 last_head = per_cpu->head[ per_cpu->tail_head_index ];
 last_tail = per_cpu->tail[ per_cpu->tail_head_index ];
@@ -192,7 +193,8 @@ static void resolve_hold_back(
   const rtems_record_item_64 *item;
 
   item = &per_cpu->items[ index ];
-  visit( ctx, item->event, item->data );
+  status = visit( ctx, item->event, item->data );
+  _Assert_Unused_variable_equals(status, RTEMS_RECORD_CLIENT_SUCCESS);
 }
   }
 }
-- 
1.8.3.1

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


[PATCH v2 3/4] getgrent.c: Fix Unchecked return value error (CID #1459004)

2021-02-26 Thread Ryan Long
CID 1459004: Unchecked return value in endgrent().

Closes #4261
---
 cpukit/libcsupport/src/getgrent.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cpukit/libcsupport/src/getgrent.c 
b/cpukit/libcsupport/src/getgrent.c
index b358cb9..de56430 100644
--- a/cpukit/libcsupport/src/getgrent.c
+++ b/cpukit/libcsupport/src/getgrent.c
@@ -95,6 +95,7 @@ void setgrent(void)
 void endgrent(void)
 {
   grp_context *ctx = grp_get_context();
+  int  sc;
 
   if (ctx == NULL)
 return;
@@ -104,5 +105,6 @@ void endgrent(void)
   }
 
   free(ctx);
-  pthread_setspecific(grp_key, NULL);
+  sc = pthread_setspecific(grp_key, NULL);
+  _Assert_Unused_variable_equals(sc, 0);
 }
-- 
1.8.3.1

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


[PATCH v2 4/4] rtems-debugger-threads.c: Fix Unchecked return value error (CID #1468688)

2021-02-26 Thread Ryan Long
CID 1468688: Unchecked return value in snapshot_thread().

Closes #4262
---
 cpukit/libdebugger/rtems-debugger-threads.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cpukit/libdebugger/rtems-debugger-threads.c 
b/cpukit/libdebugger/rtems-debugger-threads.c
index 5b96e5f..e6ffe4a 100644
--- a/cpukit/libdebugger/rtems-debugger-threads.c
+++ b/cpukit/libdebugger/rtems-debugger-threads.c
@@ -170,6 +170,7 @@ snapshot_thread(rtems_tcb* tcb, void* arg)
   charname[RTEMS_DEBUGGER_THREAD_NAME_SIZE];
   boolexclude = false;
   size_t  i;
+  int sc;
 
   /*
* The only time the threads pointer is NULL is a realloc error so we stop
@@ -272,7 +273,8 @@ snapshot_thread(rtems_tcb* tcb, void* arg)
 /*
  * Read the target registers into the thread register array.
  */
-rtems_debugger_target_read_regs(thread);
+sc = rtems_debugger_target_read_regs(thread);
+_Assert_Unused_variable_equals(sc, 0);
 
 if (rtems_debugger_server_flag(RTEMS_DEBUGGER_FLAG_VERBOSE))
   rtems_debugger_printf("rtems-db: sys: thd: %08" PRIx32 ": signal: %d\n",
-- 
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, &nextoffset); /* skip the BEGIN_NODE */
+#ifdef __rtems__
+ (void)fdt_next_tag(fdt, parentoffset, &nextoffset); /* skip the 
BEGIN_NODE */
+#else
+  fdt_next_tag(fdt, parentoffset, &nextoffset);
+#endif
do {
offset = nextoffset;
tag = fdt_next_tag(fdt, offset, &nextoffset);
-- 
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, &selstart, &selend);
+  #ifdef __rtems__
+(void)get_selection(ed, &selstart, &selend);
+  #else
+get_selection(ed, &selstart, &selend);
+  #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, &selstart, &selend);
+  #ifdef __rtems__
+(void) get_selection(ed, &selstart, &selend);
+  #else
+get_selection(ed, &selstart, &selend);
+  #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, &nextoffset); /* skip the BEGIN_NODE */
+#ifdef __rtems__
+ (void) fdt_next_tag(fdt, parentoffset, &nextoffset); /* skip the 
BEGIN_NODE */
+#else
+  fdt_next_tag(fdt, parentoffset, &nextoffset);
+#endif
do {
offset = nextoffset;
tag = fdt_next_tag(fdt, offset, &nextoffset);
-- 
1.8.3.1

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


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

2021-03-01 Thread Ryan Long
So just send this patch to them?

-Original Message-
From: devel  On Behalf Of Gedare Bloom
Sent: Monday, March 1, 2021 1:03 PM
To: Sebastian Huber 
Cc: Ryan Long ; devel@rtems.org
Subject: Re: [PATCH 1/3] fdt_rw.c: Fix Unchecked return value (CID #1047324)

On Mon, Mar 1, 2021 at 11:49 AM Sebastian Huber 
 wrote:
>
> On 01/03/2021 17:56, Gedare Bloom wrote:
>
> > On Mon, Mar 1, 2021 at 9:24 AM Ryan Long  wrote:
> >> 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
> > I think it was suggested to attempt to provide this in the upstream for dtc?
> Yes, please at least report the issue upstream and send a patch to 
> their mailing list. They are usually quite responsive.
>
+1  send the patch to them before we consider including it in rtems.

> --
> embedded brains GmbH
> Herr Sebastian HUBER
> Dornierstr. 4
> 82178 Puchheim
> Germany
> email: sebastian.hu...@embedded-brains.de
> phone: +49-89-18 94 741 - 16
> fax:   +49-89-18 94 741 - 08
>
> Registergericht: Amtsgericht München
> Registernummer: HRB 157899
> Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas 
> Dörfler Unsere Datenschutzerklärung finden Sie hier:
> https://embedded-brains.de/datenschutzerklaerung/
>
___
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 1/3] grtc.c: Fix four Missing break in switch Coverity errors

2021-03-03 Thread Ryan Long
CID 1399761: Missing break in switch in process_dma().
CID 1399765: Missing break in switch in process_dma().
CID 1399766: Missing break in switch in process_dma().
CID 1399777: Missing break in switch in process_dma().

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

diff --git a/bsps/shared/grlib/tmtc/grtc.c b/bsps/shared/grlib/tmtc/grtc.c
index e9acea4..f734f2e 100644
--- a/bsps/shared/grlib/tmtc/grtc.c
+++ b/bsps/shared/grlib/tmtc/grtc.c
@@ -1365,6 +1365,7 @@ static int process_dma(struct grtc_priv *pDev)
/* Start of frame found, Try to copy header */
pDev->frm = NULL;
pDev->frame_state = FRM_STATE_HDR;
+   /* Fall through */
 
case FRM_STATE_HDR:
DBG2("FRAME_STATE_HDR\n");
@@ -1396,6 +1397,7 @@ static int process_dma(struct grtc_priv *pDev)
return -1;
}
pDev->frame_state = FRM_STATE_ALLOC;
+   /* Fall through */
 
case FRM_STATE_ALLOC:
DBG2("FRAME_STATE_ALLOC\n");
@@ -1449,6 +1451,7 @@ static int process_dma(struct grtc_priv *pDev)
 
pDev->frame_state = FRM_STATE_PAYLOAD;
pDev->frm = frm;
+   /* Fall through */
 
case FRM_STATE_PAYLOAD:
DBG2("FRAME_STATE_PAYLOAD\n");
@@ -1476,6 +1479,7 @@ static int process_dma(struct grtc_priv *pDev)
}
frm->len += ret;
pDev->frame_state = FRM_STATE_FILLER;
+   /* Fall through */
 
case FRM_STATE_FILLER:
DBG2("FRAME_STATE_FILLER\n");
-- 
1.8.3.1

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


[PATCH 0/3] Fix Missing break in switch Coverity issues

2021-03-03 Thread Ryan Long
Hi,

To fix these Coverity issues, I just needed to add a comment to tell
Coverity to ignore the error. I did this using the same method as shown
in this article
https://www.synopsys.com/blogs/software-security/gimme-a-break/.

Thanks,
Ryan

Ryan Long (3):
  grtc.c: Fix four Missing break in switch Coverity errors
  cpuusagetop.c: Fix three Missing break in switch Coverity errors
  pci_cfg_read.c: Fix Missing break in switch (CID #1399723)

 bsps/shared/grlib/tmtc/grtc.c   | 4 
 cpukit/libmisc/cpuuse/cpuusagetop.c | 3 +++
 cpukit/libpci/pci_cfg_read.c| 1 +
 3 files changed, 8 insertions(+)

-- 
1.8.3.1

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


[PATCH 2/3] cpuusagetop.c: Fix three Missing break in switch Coverity errors

2021-03-03 Thread Ryan Long
CID 1399726: Missing break in switch in task_usage().
CID 1399728: Missing break in switch in task_usage().
CID 1399742: Missing break in switch in task_usage().

Closes #4278
---
 cpukit/libmisc/cpuuse/cpuusagetop.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cpukit/libmisc/cpuuse/cpuusagetop.c 
b/cpukit/libmisc/cpuuse/cpuusagetop.c
index 9f19b27..dad11ad 100644
--- a/cpukit/libmisc/cpuuse/cpuusagetop.c
+++ b/cpukit/libmisc/cpuuse/cpuusagetop.c
@@ -228,9 +228,11 @@ task_usage(Thread_Control* thread, void* arg)
   if (CPU_usage_Equal_to(&usage, &data->zero) ||
   CPU_usage_Less_than(&usage, &data->usage[j]))
 continue;
+  /* Fall through */
 case RTEMS_TOP_SORT_REAL_PRI:
   if (thread->Real_priority.priority > 
data->tasks[j]->Real_priority.priority)
 continue;
+  /* Fall through */
 case RTEMS_TOP_SORT_CURRENT_PRI:
   if (
 _Thread_Get_priority( thread )
@@ -238,6 +240,7 @@ task_usage(Thread_Control* thread, void* arg)
   ) {
 continue;
   }
+  /* Fall through */
 case RTEMS_TOP_SORT_ID:
   if (thread->Object.id < data->tasks[j]->Object.id)
 continue;
-- 
1.8.3.1

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


[PATCH 3/3] pci_cfg_read.c: Fix Missing break in switch (CID #1399723)

2021-03-03 Thread Ryan Long
CID 1399723: Missing break in switch in pci_read_addressable().

Closes #4279
---
 cpukit/libpci/pci_cfg_read.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cpukit/libpci/pci_cfg_read.c b/cpukit/libpci/pci_cfg_read.c
index 0783743..3cb6f86 100644
--- a/cpukit/libpci/pci_cfg_read.c
+++ b/cpukit/libpci/pci_cfg_read.c
@@ -73,6 +73,7 @@ static int pci_read_addressable(struct pci_dev *dev, struct 
pci_res *res)
break;
case PCI_RES_MEM:
range1 = &bus->dev.resources[BRIDGE_RES_MEM];
+   /* Fall through */
default:
case PCI_RES_MEMIO:
range0 = &bus->dev.resources[BRIDGE_RES_MEMIO];
-- 
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(&tv, 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, &fl);
+   sc = fcntl(state_fd, F_SETLK, &fl);
+   _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 03/12] pwdgrp.c: Fix Unchecked return value from library (CID #1255518)

2021-03-04 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 04/12] gr_rasta_spw_router.c: Fix Unchecked return value from library (CID #1399760)

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

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

diff --git a/bsps/shared/grlib/pci/gr_rasta_spw_router.c 
b/bsps/shared/grlib/pci/gr_rasta_spw_router.c
index 6efbaa4..33168cf 100644
--- a/bsps/shared/grlib/pci/gr_rasta_spw_router.c
+++ b/bsps/shared/grlib/pci/gr_rasta_spw_router.c
@@ -394,6 +394,7 @@ int gr_rasta_spw_router_init1(struct drvmgr_dev *dev)
uint32_t bar0, bar0_size;
union drvmgr_key_value *value;
int resources_cnt;
+   int sc;
 
priv = dev->priv;
if (!priv)
@@ -410,7 +411,8 @@ int gr_rasta_spw_router_init1(struct drvmgr_dev *dev)
 
strcpy(priv->prefix, "/dev/spwrouter0");
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 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 grlib/gr device driver Coverity errors

2021-03-04 Thread Ryan Long
Hi,

Here are the fixes for the Coverity errors with grlib/gr device drivers.

The types of issues fixed were:
- Unchecked return value
- Unchecked return value from library
- Unsigned compared against 0
- Unused value

For the "Unsigned compared against 0" errors in satcan.c, the first if
statements were not being used, so they were taken out.

Thanks,
Ryan

Ryan Long (12):
  grspw.c: Fix Unchecked return value (CID #1399781)
  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)
  satcan.c: Fix Unsigned compared against 0 (CID #1399768)
  b1553brm.c: Fix Unsigned compared against 0 (CID #1399773)
  grcan.c: Fix Unused value (CID #1437613)

 bsps/shared/grlib/1553/b1553brm.c   |  2 +-
 bsps/shared/grlib/can/grcan.c   |  2 +-
 bsps/shared/grlib/can/satcan.c  | 16 
 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/shared/grlib/spw/grspw.c   |  7 +--
 bsps/sparc/shared/pci/gr_cpci_gr740.c   |  4 +++-
 bsps/sparc/shared/pci/gr_leon4_n2x.c|  4 +++-
 12 files changed, 35 insertions(+), 24 deletions(-)

-- 
1.8.3.1

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


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

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

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

diff --git a/bsps/shared/grlib/pci/gr_rasta_spw_router.c 
b/bsps/shared/grlib/pci/gr_rasta_spw_router.c
index 6efbaa4..33168cf 100644
--- a/bsps/shared/grlib/pci/gr_rasta_spw_router.c
+++ b/bsps/shared/grlib/pci/gr_rasta_spw_router.c
@@ -394,6 +394,7 @@ int gr_rasta_spw_router_init1(struct drvmgr_dev *dev)
uint32_t bar0, bar0_size;
union drvmgr_key_value *value;
int resources_cnt;
+   int sc;
 
priv = dev->priv;
if (!priv)
@@ -410,7 +411,8 @@ int gr_rasta_spw_router_init1(struct drvmgr_dev *dev)
 
strcpy(priv->prefix, "/dev/spwrouter0");
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 01/12] grspw.c: Fix Unchecked return value (CID #1399781)

2021-03-04 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 03/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 04/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 05/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 06/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 07/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 08/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 09/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 10/12] satcan.c: Fix Unsigned compared against 0 (CID #1399768)

2021-03-04 Thread Ryan Long
CID 1399768: Unsigned compared against 0 in satcan_ioctl().

Closes #4294
---
 bsps/shared/grlib/can/satcan.c | 16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/bsps/shared/grlib/can/satcan.c b/bsps/shared/grlib/can/satcan.c
index c3fdc15..52e674c 100644
--- a/bsps/shared/grlib/can/satcan.c
+++ b/bsps/shared/grlib/can/satcan.c
@@ -239,9 +239,7 @@ static rtems_device_driver 
satcan_ioctl(rtems_device_major_number major, rtems_d
/* Get regmod structure from argument */
regmod = (satcan_regmod*)ioarg->buffer;
DBG("SatCAN: ioctl: getting register %d\n\r", regmod->reg);
-   if (regmod->reg < 0)
-   return RTEMS_INVALID_NAME;
-   else if (regmod->reg <= SATCAN_FILTER_STOP)
+   if (regmod->reg <= SATCAN_FILTER_STOP)
regmod->val = regs->satcan[regmod->reg];
else if (regmod->reg == SATCAN_WCTRL)
regmod->val = regs->ctrl;
@@ -260,9 +258,7 @@ static rtems_device_driver 
satcan_ioctl(rtems_device_major_number major, rtems_d
regmod = (satcan_regmod*)ioarg->buffer;
DBG("SatCAN: ioctl: setting register %d, value %x\n\r", 
regmod->reg, regmod->val);
-   if (regmod->reg < 0)
-   return RTEMS_INVALID_NAME;
-   else if (regmod->reg <= SATCAN_FILTER_STOP)
+   if (regmod->reg <= SATCAN_FILTER_STOP)
regs->satcan[regmod->reg] = regmod->val;
else if (regmod->reg == SATCAN_WCTRL)
regs->ctrl = regmod->val;
@@ -281,9 +277,7 @@ static rtems_device_driver 
satcan_ioctl(rtems_device_major_number major, rtems_d
regmod = (satcan_regmod*)ioarg->buffer;
DBG("SatCAN: ioctl: or:ing register %d, with value %x\n\r",
regmod->reg, regmod->val);
-   if (regmod->reg < 0)
-   return RTEMS_INVALID_NAME;
-   else if (regmod->reg <= SATCAN_FILTER_STOP)
+   if (regmod->reg <= SATCAN_FILTER_STOP)
regs->satcan[regmod->reg] |= regmod->val;
else if (regmod->reg == SATCAN_WCTRL)
regs->ctrl |= regmod->val;
@@ -302,9 +296,7 @@ static rtems_device_driver 
satcan_ioctl(rtems_device_major_number major, rtems_d
regmod = (satcan_regmod*)ioarg->buffer;
DBG("SatCAN: ioctl: masking register %d, with value %x\n\r",
regmod->reg, regmod->val);
-   if (regmod->reg < 0)
-   return RTEMS_INVALID_NAME;
-   else if (regmod->reg <= SATCAN_FILTER_STOP)
+   if (regmod->reg <= SATCAN_FILTER_STOP)
regs->satcan[regmod->reg] &= regmod->val;
else if (regmod->reg == SATCAN_WCTRL)
regs->ctrl &= regmod->val;
-- 
1.8.3.1

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


[PATCH 11/12] b1553brm.c: Fix Unsigned compared against 0 (CID #1399773)

2021-03-04 Thread Ryan Long
CID 1399773: Unsigned compared against 0 in brm_write().

Closes #4295
---
 bsps/shared/grlib/1553/b1553brm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bsps/shared/grlib/1553/b1553brm.c 
b/bsps/shared/grlib/1553/b1553brm.c
index 694f585..484ee6d 100644
--- a/bsps/shared/grlib/1553/b1553brm.c
+++ b/bsps/shared/grlib/1553/b1553brm.c
@@ -982,7 +982,7 @@ static rtems_device_driver 
brm_write(rtems_device_major_number major, rtems_devi
 
rw_args->bytes_moved = count; 
 
-   if (count >= 0) {
+   if (count > 0) {
return RTEMS_SUCCESSFUL;
}
return RTEMS_UNSATISFIED;
-- 
1.8.3.1

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


[PATCH 12/12] grcan.c: Fix Unused value (CID #1437613)

2021-03-04 Thread Ryan Long
CID 1437613: Unused value in grcan_set_filter().
This fix was recommended by Daniel Hellstrom (dan...@gaisler.com).

Closes #4301
---
 bsps/shared/grlib/can/grcan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bsps/shared/grlib/can/grcan.c b/bsps/shared/grlib/can/grcan.c
index d69d99d..a446d04 100644
--- a/bsps/shared/grlib/can/grcan.c
+++ b/bsps/shared/grlib/can/grcan.c
@@ -1787,7 +1787,7 @@ int grcan_set_sfilter(void *d, const struct grcan_filter 
*filter)
if ( !filter ){
/* disable TX/RX SYNC filtering */
pDev->sfilter.mask = 0x;
-   pDev->sfilter.mask = 0;
+   pDev->sfilter.code = 0;
 
 /* disable Sync interrupt */
SPIN_LOCK_IRQ(&pDev->devlock, oldLevel);
-- 
1.8.3.1

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


[PATCH] Fix for grtc.c

2021-03-04 Thread Ryan Long
Hi,

I forgot to include this patch. Sorry about that.

Thanks,
Ryan

Ryan Long (1):
  grtc.c: Fix four Missing break in switch Coverity errors

 bsps/shared/grlib/tmtc/grtc.c | 4 
 1 file changed, 4 insertions(+)

-- 
1.8.3.1

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


[PATCH] grtc.c: Fix four Missing break in switch Coverity errors

2021-03-04 Thread Ryan Long
CID 1399761: Missing break in switch in process_dma().
CID 1399765: Missing break in switch in process_dma().
CID 1399766: Missing break in switch in process_dma().
CID 1399777: Missing break in switch in process_dma().

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

diff --git a/bsps/shared/grlib/tmtc/grtc.c b/bsps/shared/grlib/tmtc/grtc.c
index e9acea4..f734f2e 100644
--- a/bsps/shared/grlib/tmtc/grtc.c
+++ b/bsps/shared/grlib/tmtc/grtc.c
@@ -1365,6 +1365,7 @@ static int process_dma(struct grtc_priv *pDev)
/* Start of frame found, Try to copy header */
pDev->frm = NULL;
pDev->frame_state = FRM_STATE_HDR;
+   /* Fall through */
 
case FRM_STATE_HDR:
DBG2("FRAME_STATE_HDR\n");
@@ -1396,6 +1397,7 @@ static int process_dma(struct grtc_priv *pDev)
return -1;
}
pDev->frame_state = FRM_STATE_ALLOC;
+   /* Fall through */
 
case FRM_STATE_ALLOC:
DBG2("FRAME_STATE_ALLOC\n");
@@ -1449,6 +1451,7 @@ static int process_dma(struct grtc_priv *pDev)
 
pDev->frame_state = FRM_STATE_PAYLOAD;
pDev->frm = frm;
+   /* Fall through */
 
case FRM_STATE_PAYLOAD:
DBG2("FRAME_STATE_PAYLOAD\n");
@@ -1476,6 +1479,7 @@ static int process_dma(struct grtc_priv *pDev)
}
frm->len += ret;
pDev->frame_state = FRM_STATE_FILLER;
+   /* Fall through */
 
case FRM_STATE_FILLER:
DBG2("FRAME_STATE_FILLER\n");
-- 
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(&tv, 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, &fl);
+   sc = fcntl(state_fd, F_SETLK, &fl);
+   _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(&tv, 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, &fl);
+   sc = fcntl(state_fd, F_SETLK, &fl);
+   _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, &selstart, &selend);
+  (void) get_selection(ed, &selstart, &selend);
   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] main_help.c: Fix Unchecked return value from library (CID #1437650)

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

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

diff --git a/cpukit/libmisc/shell/main_help.c b/cpukit/libmisc/shell/main_help.c
index 9f59e9d..564bc30 100644
--- a/cpukit/libmisc/shell/main_help.c
+++ b/cpukit/libmisc/shell/main_help.c
@@ -148,7 +148,7 @@ static int rtems_shell_help(
 line+= rtems_shell_help_cmd(shell_cmd);
   if (lines && (line > lines)) {
 printf("Press any key to continue...");
-getchar();
+(void) getchar();
 printf("\n");
 line = 0;
   }
-- 
1.8.3.1

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


[PATCH] shell.c: Dereference after null check (CID #26083)

2021-03-10 Thread Ryan Long
CID 26083: Dereference after null check in rtems_shell_login().

Closes #4327
---
 cpukit/libmisc/shell/shell.c | 196 ++-
 1 file changed, 99 insertions(+), 97 deletions(-)

diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c
index 1e5962b..b724b1d 100644
--- a/cpukit/libmisc/shell/shell.c
+++ b/cpukit/libmisc/shell/shell.c
@@ -683,109 +683,111 @@ static bool rtems_shell_login(rtems_shell_env_t *env, 
FILE * in,FILE * out)
   intc;
   time_t t;
 
-  if (out) {
-if ((env->devname[5]!='p')||
-(env->devname[6]!='t')||
-(env->devname[7]!='y')) {
-  fd = fopen("/etc/issue","r");
-  if (fd) {
-while ((c = fgetc(fd)) != EOF) {
-  if (c=='@')  {
-switch (c = fgetc(fd)) {
-  case 'L':
-fprintf(out,"%s", env->devname);
-break;
-  case 'B':
-fprintf(out,"0");
-break;
-  case 'T':
-  case 'D':
-time(&t);
-fprintf(out,"%s",ctime(&t));
-break;
-  case 'S':
-fprintf(out,"RTEMS");
-break;
-  case 'V':
-fprintf(
-  out,
-  "%s\n%s",
-  rtems_get_version_string(),
-  rtems_get_copyright_notice()
-);
-break;
-  case '@':
-fprintf(out,"@");
-break;
-  default :
-fprintf(out,"@%c",c);
-break;
-}
-  } else if (c=='\\')  {
-switch(c=fgetc(fd)) {
-  case '\\': fprintf(out,"\\"); break;
-  case 'b':  fprintf(out,"\b"); break;
-  case 'f':  fprintf(out,"\f"); break;
-  case 'n':  fprintf(out,"\n"); break;
-  case 'r':  fprintf(out,"\r"); break;
-  case 's':  fprintf(out," ");  break;
-  case 't':  fprintf(out,"\t"); break;
-  case '@':  fprintf(out,"@");  break;
-}
-  } else {
-fputc(c,out);
+  if (out == NULL) {
+return false;
+  }
+
+  if ((env->devname[5]!='p')||
+  (env->devname[6]!='t')||
+  (env->devname[7]!='y')) {
+fd = fopen("/etc/issue","r");
+if (fd) {
+  while ((c = fgetc(fd)) != EOF) {
+if (c=='@')  {
+  switch (c = fgetc(fd)) {
+case 'L':
+  fprintf(out,"%s", env->devname);
+  break;
+case 'B':
+  fprintf(out,"0");
+  break;
+case 'T':
+case 'D':
+  time(&t);
+  fprintf(out,"%s",ctime(&t));
+  break;
+case 'S':
+  fprintf(out,"RTEMS");
+  break;
+case 'V':
+  fprintf(
+out,
+"%s\n%s",
+rtems_get_version_string(),
+rtems_get_copyright_notice()
+  );
+  break;
+case '@':
+  fprintf(out,"@");
+  break;
+default :
+  fprintf(out,"@%c",c);
+  break;
+  }
+} else if (c=='\\')  {
+  switch(c=fgetc(fd)) {
+case '\\': fprintf(out,"\\"); break;
+case 'b':  fprintf(out,"\b"); break;
+case 'f':  fprintf(out,"\f"); break;
+case 'n':  fprintf(out,"\n"); break;
+case 'r':  fprintf(out,"\r"); break;
+case 's':  fprintf(out," ");  break;
+case 't':  fprintf(out,"\t"); break;
+case '@':  fprintf(out,"@");  break;
   }
+} else {
+  fputc(c,out);
 }
-fclose(fd);
   }
-} else {
-  fd = fopen("/etc/issue.net","r");
-  if (fd) {
-while ((c=fgetc(fd))!=EOF) {
-  if (c=='%')  {
-switch(c=fgetc(fd)) {
-  case 't':
-fprintf(out,"%s", env->devname);
-break;
-  case 'h':
-fprintf(out,"0");
-break;
-  case 'D':
-fprintf(out," ");
-break;
-  case 'd':
-time(&t);
-fprintf(out,"%s",ctime(&t));
-break;
-  case 's':
-fprintf(out,"RTEMS");
-break;
-  case 'm':
-fprintf(out,"(" CPU_NAME "/" CPU_MODEL_NAME ")");
-break;
-  case 'r':
-fprintf(out,rtems_get_version_string());
-break;
-  case 'v':
-fprintf(
-  out,
-  "%s\n%s",
-  rtems_get_version_string(),
-  rtems_get_copyright_notice()
-);
-   break;
- case '%':fprintf(out,"%%");
-

RE: [PATCH] shell.c: Dereference after null check (CID #26083)

2021-03-11 Thread Ryan Long
After talking with Joel, we determined that 'out' shouldn’t be NULL by the time 
it gets to rtems_shell_login(). 

We think that we should put in an assert to check whether stdin and stdout is 
NULL at https://git.rtems.org/rtems/tree/cpukit/libmisc/shell/shell.c#n968.
Instead of the check that I put in for this patch, we think it's better to just 
put another assert at 
https://git.rtems.org/rtems/tree/cpukit/libmisc/shell/shell.c#n791 for 'out' 
out of paranoia and to get rid of the Coverity issue.

-Original Message-
From: Gedare Bloom  
Sent: Wednesday, March 10, 2021 4:50 PM
To: Ryan Long 
Cc: devel@rtems.org
Subject: Re: [PATCH] shell.c: Dereference after null check (CID #26083)

I need an explanation, I don't know if it is correct, or if someone can open a 
shell without an 'out' FILE?

On Wed, Mar 10, 2021 at 12:10 PM Ryan Long  wrote:
>
> CID 26083: Dereference after null check in rtems_shell_login().
>
> Closes #4327
> ---
>  cpukit/libmisc/shell/shell.c | 196 
> ++-
>  1 file changed, 99 insertions(+), 97 deletions(-)
>
> diff --git a/cpukit/libmisc/shell/shell.c 
> b/cpukit/libmisc/shell/shell.c index 1e5962b..b724b1d 100644
> --- a/cpukit/libmisc/shell/shell.c
> +++ b/cpukit/libmisc/shell/shell.c
> @@ -683,109 +683,111 @@ static bool rtems_shell_login(rtems_shell_env_t *env, 
> FILE * in,FILE * out)
>intc;
>time_t t;
>
> -  if (out) {
> -if ((env->devname[5]!='p')||
> -(env->devname[6]!='t')||
> -(env->devname[7]!='y')) {
> -  fd = fopen("/etc/issue","r");
> -  if (fd) {
> -while ((c = fgetc(fd)) != EOF) {
> -  if (c=='@')  {
> -switch (c = fgetc(fd)) {
> -  case 'L':
> -fprintf(out,"%s", env->devname);
> -break;
> -  case 'B':
> -fprintf(out,"0");
> -break;
> -  case 'T':
> -  case 'D':
> -time(&t);
> -fprintf(out,"%s",ctime(&t));
> -break;
> -  case 'S':
> -fprintf(out,"RTEMS");
> -break;
> -  case 'V':
> -fprintf(
> -  out,
> -  "%s\n%s",
> -  rtems_get_version_string(),
> -  rtems_get_copyright_notice()
> -);
> -break;
> -  case '@':
> -fprintf(out,"@");
> -break;
> -  default :
> -fprintf(out,"@%c",c);
> -break;
> -}
> -  } else if (c=='\\')  {
> -switch(c=fgetc(fd)) {
> -  case '\\': fprintf(out,"\\"); break;
> -  case 'b':  fprintf(out,"\b"); break;
> -  case 'f':  fprintf(out,"\f"); break;
> -  case 'n':  fprintf(out,"\n"); break;
> -  case 'r':  fprintf(out,"\r"); break;
> -  case 's':  fprintf(out," ");  break;
> -  case 't':  fprintf(out,"\t"); break;
> -  case '@':  fprintf(out,"@");  break;
> -}
> -  } else {
> -fputc(c,out);
> +  if (out == NULL) {
> +return false;
> +  }
> +
> +  if ((env->devname[5]!='p')||
> +  (env->devname[6]!='t')||
> +  (env->devname[7]!='y')) {
> +fd = fopen("/etc/issue","r");
> +if (fd) {
> +  while ((c = fgetc(fd)) != EOF) {
> +if (c=='@')  {
> +  switch (c = fgetc(fd)) {
> +case 'L':
> +  fprintf(out,"%s", env->devname);
> +  break;
> +case 'B':
> +  fprintf(out,"0");
> +  break;
> +case 'T':
> +case 'D':
> +  time(&t);
> +  fprintf(out,"%s",ctime(&t));
> +  break;
> +case 'S':
> +  fprintf(out,"RTEMS");
> +  break;
> +case 'V':
> +  fprintf(
> +out,
> +"%s\n%s",
> +rtems_get_version_stri

[PATCH v2] shell.c: Fix Dereference after null check (CID #26083)

2021-03-11 Thread Ryan Long
CID 26083: Dereference after null check in rtems_shell_login().

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

diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c
index 1e5962b..ad47460 100644
--- a/cpukit/libmisc/shell/shell.c
+++ b/cpukit/libmisc/shell/shell.c
@@ -789,6 +789,8 @@ static bool rtems_shell_login(rtems_shell_env_t *env, FILE 
* in,FILE * out)
 }
   }
 
+  _Assert(out != NULL);
+
   return rtems_shell_login_prompt(in, out, env->devname, env->login_check);
 }
 
@@ -966,6 +968,9 @@ bool rtems_shell_main_loop(
 "shell: cannot allocate prompt memory\n");
   }
 
+  _Assert(stdin != NULL);
+  _Assert(stdout != NULL);
+
   shell_std_debug("child out: %d (%p)\n", fileno(stdout), stdout);
   shell_std_debug("child  in: %d (%p)\n", fileno(stdin), stdin);
 
-- 
1.8.3.1

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


[PATCH 0/2] Fix Dereference after null check Coverity issues

2021-03-12 Thread Ryan Long
Hi,

For these issues, I needed to make sure that a value that could be NULL
would not be dereferenced. For objectextendinformation.c, an assert was
added, and in main_rtrace.c a return was added to the check.

Thanks,
Ryan

Ryan Long (2):
  objectextendinformation.c: Fix Dereference after null check (CID
#26033)
  main_rtrace.c: Fix Dereference after null check (CID #1399709)

 cpukit/libmisc/shell/main_rtrace.c |  1 +
 cpukit/score/src/objectextendinformation.c | 11 +++
 2 files changed, 12 insertions(+)

-- 
1.8.3.1

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


[PATCH 1/2] objectextendinformation.c: Fix Dereference after null check (CID #26033)

2021-03-12 Thread Ryan Long
CID 26033: Dereference after null check in _Objects_Extend_information().

Closes #4326
---
 cpukit/score/src/objectextendinformation.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/cpukit/score/src/objectextendinformation.c 
b/cpukit/score/src/objectextendinformation.c
index 9796eb9..c669301 100644
--- a/cpukit/score/src/objectextendinformation.c
+++ b/cpukit/score/src/objectextendinformation.c
@@ -171,6 +171,17 @@ Objects_Maximum _Objects_Extend_information(
 
 if ( old_maximum > extend_count ) {
   /*
+   * Coverity thinks there is a way for this to be NULL (CID #26033).
+   * After much time spent analyzing this, no one has identified the
+   * conditions where this can actually occur. Adding this _Assert ensures
+   * that it is never NULL. If this assert is triggered, condition
+   * generating this case will have been identified and it can be revisted.
+   * This is being done out of an abundance of caution since we could have
+   * easily flagged this as a false positive and ignored it completely.
+   */
+  _Assert(information->object_blocks != NULL);
+
+  /*
*  Copy each section of the table over. This has to be performed as
*  separate parts as size of each block has changed.
*/
-- 
1.8.3.1

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


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

2021-03-12 Thread Ryan Long
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 0/5] Fix Resource leak Coverity issues

2021-03-12 Thread Ryan Long
Hi,

For these issues I just needed to free dynamically allocated variables.
Most of these additions were in areas that were error-checking and
returning early. For flashdisk.c, this was the case as well, but it had
nested, dynamically allocated list of values that had to be freed using
a for loop.

Thanks,
Ryan 

Ryan Long (5):
  hexdump-parse.c: Fix Resource leak (CID #26032)
  rtems-fdt.c: Fix Resource leak (CID #1437645)
  nvdisk.c: Fix Resource leak (CID #1439297)
  flashdisk.c: Fix Resource leak (CID #1439298)
  rtl-shell.c: Resource leak (CID #1444140)

 cpukit/libblock/src/flashdisk.c  | 42 ++--
 cpukit/libblock/src/nvdisk.c |  8 ++-
 cpukit/libdl/rtl-shell.c |  3 +++
 cpukit/libmisc/rtems-fdt/rtems-fdt.c |  1 +
 cpukit/libmisc/shell/hexdump-parse.c |  3 +++
 5 files changed, 45 insertions(+), 12 deletions(-)

-- 
1.8.3.1

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


[PATCH 2/5] rtems-fdt.c: Fix Resource leak (CID #1437645)

2021-03-12 Thread Ryan Long
CID 1437645: Resource leak in rtems_fdt_load().

Closes #4297
---
 cpukit/libmisc/rtems-fdt/rtems-fdt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cpukit/libmisc/rtems-fdt/rtems-fdt.c 
b/cpukit/libmisc/rtems-fdt/rtems-fdt.c
index 0ea3653..5bb7ce0 100644
--- a/cpukit/libmisc/rtems-fdt/rtems-fdt.c
+++ b/cpukit/libmisc/rtems-fdt/rtems-fdt.c
@@ -611,6 +611,7 @@ rtems_fdt_load (const char* filename, rtems_fdt_handle* 
handle)
 return fe;
   }
 
+  close (bf);
   return 0;
 }
 
-- 
1.8.3.1

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


[PATCH 3/5] nvdisk.c: Fix Resource leak (CID #1439297)

2021-03-12 Thread Ryan Long
CID 1439297: Resource leak in rtems_nvdisk_initialize().

Closes #4298
---
 cpukit/libblock/src/nvdisk.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/cpukit/libblock/src/nvdisk.c b/cpukit/libblock/src/nvdisk.c
index a7f4167..d742baf 100644
--- a/cpukit/libblock/src/nvdisk.c
+++ b/cpukit/libblock/src/nvdisk.c
@@ -766,8 +766,10 @@ rtems_nvdisk_initialize (rtems_device_major_number major 
RTEMS_UNUSED,
 nvd->info_level   = c->info_level;
 
 nvd->devices = calloc (c->device_count, sizeof (rtems_nvdisk_device_ctl));
-if (!nvd->devices)
+if (!nvd->devices) {
+  free(nvd);
   return RTEMS_NO_MEMORY;
+}
 
 for (device = 0; device < c->device_count; device++)
 {
@@ -790,6 +792,8 @@ rtems_nvdisk_initialize (rtems_device_major_number major 
RTEMS_UNUSED,
  rtems_nvdisk_ioctl, nvd);
 if (sc != RTEMS_SUCCESSFUL)
 {
+  free(nvd->devices);
+  free(nvd);
   rtems_nvdisk_error ("disk create phy failed");
   return sc;
 }
@@ -797,5 +801,7 @@ rtems_nvdisk_initialize (rtems_device_major_number major 
RTEMS_UNUSED,
 rtems_mutex_init (&nvd->lock, "NV Disk");
   }
 
+  free(nvd->devices);
+  free(nvd);
   return RTEMS_SUCCESSFUL;
 }
-- 
1.8.3.1

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


[PATCH 1/5] hexdump-parse.c: Fix Resource leak (CID #26032)

2021-03-12 Thread Ryan Long
CID 26032: Resource leak in rtems_shell_hexdump_rewrite().

Closes #4296
---
 cpukit/libmisc/shell/hexdump-parse.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cpukit/libmisc/shell/hexdump-parse.c 
b/cpukit/libmisc/shell/hexdump-parse.c
index 88b9d56..5b56bbf 100644
--- a/cpukit/libmisc/shell/hexdump-parse.c
+++ b/cpukit/libmisc/shell/hexdump-parse.c
@@ -462,6 +462,9 @@ isint2: 
switch(fu->bcnt) {
(void)printf("\n");
}
 #endif
+#ifdef __rtems__
+   free(nextpr);
+#endif
 }
 
 void
-- 
1.8.3.1

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


[PATCH 5/5] rtl-shell.c: Resource leak (CID #1444140)

2021-03-12 Thread Ryan Long
CID 1444140: Resource leak in rtems_rtl_shell_object().

Closes #4300
---
 cpukit/libdl/rtl-shell.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cpukit/libdl/rtl-shell.c b/cpukit/libdl/rtl-shell.c
index 9f8a136..bcecdd4 100644
--- a/cpukit/libdl/rtl-shell.c
+++ b/cpukit/libdl/rtl-shell.c
@@ -733,14 +733,17 @@ rtems_rtl_shell_object (const rtems_printer* printer, int 
argc, char* argv[])
 if (dlinfo (RTLD_SELF, RTLD_DI_UNRESOLVED, &unresolved) < 0)
 {
   rtems_printf (printer, "error: %s: %s\n", argv[arg], dlerror ());
+  (void) dlclose (handle);
   return 1;
 }
 
 if (unresolved != 0)
 {
   rtems_printf (printer, "warning: unresolved symbols present\n");
+  (void) dlclose (handle);
   return 1;
 }
+  (void) dlclose (handle);
   }
   else if (strcmp (argv[arg], "unload") == 0)
   {
-- 
1.8.3.1

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


[PATCH 4/5] flashdisk.c: Fix Resource leak (CID #1439298)

2021-03-12 Thread Ryan Long
CID 1439298: Resource leak in rtems_fdisk_initialize().

Closes #4299
---
 cpukit/libblock/src/flashdisk.c | 42 ++---
 1 file changed, 31 insertions(+), 11 deletions(-)

diff --git a/cpukit/libblock/src/flashdisk.c b/cpukit/libblock/src/flashdisk.c
index 91f99e0..c4bac82 100644
--- a/cpukit/libblock/src/flashdisk.c
+++ b/cpukit/libblock/src/flashdisk.c
@@ -2463,6 +2463,7 @@ rtems_fdisk_initialize (rtems_device_major_number major,
   {
 char name[] = RTEMS_FLASHDISK_DEVICE_BASE_NAME "a";
 uint32_t device;
+uint32_t device_to_free;
 uint32_t blocks = 0;
 int  ret;
 
@@ -2485,18 +2486,27 @@ rtems_fdisk_initialize (rtems_device_major_number major,
  * One copy buffer of a page size.
  */
 fd->copy_buffer = malloc (c->block_size);
-if (!fd->copy_buffer)
+if (!fd->copy_buffer) {
+  free(fd);
   return RTEMS_NO_MEMORY;
+}
 
 fd->blocks = calloc (blocks, sizeof (rtems_fdisk_block_ctl));
-if (!fd->blocks)
+if (!fd->blocks) {
+  free(fd->copy_buffer);
+  free(fd);
   return RTEMS_NO_MEMORY;
+}
 
 fd->block_count = blocks;
 
 fd->devices = calloc (c->device_count, sizeof (rtems_fdisk_device_ctl));
-if (!fd->devices)
+if (!fd->devices) {
+  free (fd->blocks);
+  free (fd->copy_buffer);
+  free (fd);
   return RTEMS_NO_MEMORY;
+}
 
 rtems_mutex_init (&fd->lock, "Flash Disk");
 
@@ -2505,9 +2515,10 @@ rtems_fdisk_initialize (rtems_device_major_number major,
 if (sc != RTEMS_SUCCESSFUL)
 {
   rtems_mutex_destroy (&fd->lock);
-  free (fd->copy_buffer);
-  free (fd->blocks);
   free (fd->devices);
+  free (fd->blocks);
+  free (fd->copy_buffer);
+  free (fd);
   rtems_fdisk_error ("disk create phy failed");
   return sc;
 }
@@ -2524,11 +2535,14 @@ rtems_fdisk_initialize (rtems_device_major_number major,
  sizeof (rtems_fdisk_segment_ctl));
   if (!fd->devices[device].segments)
   {
+for (device_to_free = device - 1; device_to_free >= 0; 
device_to_free--)
+ free(fd->devices[device_to_free].segments);
 unlink (name);
 rtems_mutex_destroy (&fd->lock);
-free (fd->copy_buffer);
-free (fd->blocks);
 free (fd->devices);
+free (fd->blocks);
+free (fd->copy_buffer);
+free (fd);
 return RTEMS_NO_MEMORY;
   }
 
@@ -2559,11 +2573,14 @@ rtems_fdisk_initialize (rtems_device_major_number major,
 ret = rtems_fdisk_recover_block_mappings (fd);
 if (ret)
 {
+  for (device_to_free = device - 1; device_to_free >= 0; device_to_free--)
+free(fd->devices[device_to_free].segments);
   unlink (name);
   rtems_mutex_destroy (&fd->lock);
-  free (fd->copy_buffer);
-  free (fd->blocks);
   free (fd->devices);
+  free (fd->blocks);
+  free (fd->copy_buffer);
+  free (fd);
   rtems_fdisk_error ("recovery of disk failed: %s (%d)",
  strerror (ret), ret);
   return ret;
@@ -2572,11 +2589,14 @@ rtems_fdisk_initialize (rtems_device_major_number major,
 ret = rtems_fdisk_compact (fd);
 if (ret)
 {
+  for (device_to_free = device - 1; device_to_free >= 0; device_to_free--)
+free(fd->devices[device_to_free].segments);
   unlink (name);
   rtems_mutex_destroy (&fd->lock);
-  free (fd->copy_buffer);
-  free (fd->blocks);
   free (fd->devices);
+  free (fd->blocks);
+  free (fd->copy_buffer);
+  free (fd);
   rtems_fdisk_error ("compacting of disk failed: %s (%d)",
  strerror (ret), ret);
   return ret;
-- 
1.8.3.1

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


RE: [rtems commit] pwdgrp.c: Fix Unchecked return value from library ( CID #1255518)

2021-03-16 Thread Ryan Long
I found this error yesterday, when doing more testing based on Chris's 
feedback. I've taken out the _Assert_Unused_variable_equals() in pwdgrp.c and 
replaced it with just a (void). The test passed afterwards, but Joel wants me 
to test it a little further. I'll get the patch in to fix that by the end of 
the day. 

-Original Message-
From: Sebastian Huber  
Sent: Tuesday, March 16, 2021 6:33 AM
To: RTEMS ; Ryan Long 
Subject: Re: [rtems commit] pwdgrp.c: Fix Unchecked return value from library ( 
CID #1255518)

On 16/03/2021 12:30, Sebastian Huber wrote:

> On 08/03/2021 21:56, Joel Sherrill wrote:
>
>> Module:    rtems
>> Branch:    master
>> Commit:    55ba229d228d1b7372256978828c573dd0af56d4
>> Changeset:http://git.rtems.org/rtems/commit/?id=55ba229d228d1b7372256
>> 978828c573dd0af56d4
>>
>>
>> Author:    Ryan Long
>> Date:  Tue Mar  2 11:46:02 2021 -0500
>>
>> pwdgrp.c: Fix Unchecked return value from library (CID #1255518)
>>
>> CID 1255518: Unchecked return value from library in pwdgrp_init().
>>
>> Closes #4282
>
> I get an assertion in the tests with RTEMS_DEBUG enabled:
>
>     test start: PWDGRP 1
>
>     *** BEGIN OF TEST PWDGRP 1 ***
>
>     *** TEST VERSION: 6.0.0.ca801609a7100804520809d1407174f465befee5
>
>     *** TEST STATE: EXPECTED_PASS
>
>     *** TEST BUILD: RTEMS_DEBUG RTEMS_NETWORKING RTEMS_POSIX_API
>
>     *** TEST TOOLS: 10.2.1 20210315 (RTEMS 6, RSB 
> 62363ba982213588ef5d8bc8c4ff3acc28075f3f,
>     Newlib d10d0d9)
>
>     assertion "(sc) == (0)" failed: file 
> "/home/EB/sebastian_h/src/rtems/cpukit/libcsupport/src/pwdgrp.c",
>     line 72, function: pwdgrp_init

Also these tests:

     test start: PSXPASSWD 2

     *** BEGIN OF TEST PSXPASSWD 2 ***

     *** TEST VERSION: 6.0.0.ca801609a7100804520809d1407174f465befee5

     *** TEST STATE: EXPECTED_PASS

     *** TEST BUILD: RTEMS_DEBUG RTEMS_NETWORKING RTEMS_POSIX_API

     *** TEST TOOLS: 10.2.1 20210315 (RTEMS 6, RSB 
62363ba982213588ef5d8bc8c4ff3acc28075f3f,
     Newlib d10d0d9)

     Init - Creating /etc

     Init - Creating /etc/passwd

     Init - Creating /etc/group

     Init - setpwent() -- OK

     assertion "(sc) == (0)" failed: file 
"/home/EB/sebastian_h/src/rtems/cpukit/libcsupport/src/pwdgrp.c",

     line 72, function: pwdgrp_init


     test start: SHELL 1

     *** BEGIN OF TEST SHELL 1 ***

     *** TEST VERSION: 6.0.0.ca801609a7100804520809d1407174f465befee5

     *** TEST STATE: EXPECTED_PASS

     *** TEST BUILD: RTEMS_DEBUG RTEMS_NETWORKING RTEMS_POSIX_API

     *** TEST TOOLS: 10.2.1 20210315 (RTEMS 6, RSB 
62363ba982213588ef5d8bc8c4ff3acc28075f3f,
     Newlib d10d0d9)

     assertion "(sc) == (0)" failed: file 
"/home/EB/sebastian_h/src/rtems/cpukit/libcsupport/src/pwdgrp.c",
     line 72, function: pwdgrp_init

--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler Unsere 
Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/

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

[PATCH] pwdgrp.c: Changed assert to void to fix runtime issues (CID #1399781)

2021-03-18 Thread Ryan Long
Changed the _Assert_unused_value_equals macro to just a void due to
/etc having already been created by the network stack initialization
or an initial filesystem image.
---
 cpukit/libcsupport/src/pwdgrp.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/cpukit/libcsupport/src/pwdgrp.c b/cpukit/libcsupport/src/pwdgrp.c
index f4a10f7..edc8aff 100644
--- a/cpukit/libcsupport/src/pwdgrp.c
+++ b/cpukit/libcsupport/src/pwdgrp.c
@@ -36,7 +36,6 @@
 #include 
 
 #include 
-#include 
 
 #include "pwdgrp.h"
 
@@ -63,13 +62,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.
+   *
+   * /etc could be created by the network stack initialization or an initial
+   * filesystem image. Deliberately ignore the return value.
*/
-  sc = mkdir("/etc", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
-  _Assert_Unused_variable_equals(sc, 0);
+  (void) mkdir("/etc", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
 
   /*
*  Initialize /etc/passwd
-- 
1.8.3.1

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


RE: [PATCH] pwdgrp.c: Changed assert to void to fix runtime issues (CID #1399781)

2021-03-18 Thread Ryan Long
I didn't make another ticket. I didn't know if I needed to since this was a fix 
for a previous commit that was merged. Should I?

Moving/removing the CID number is fine with me. Whatever y'all think is best. I 
think having something in the commit message to identify that it was a Coverity 
issue fix is helpful though.

-Original Message-
From: Gedare Bloom  
Sent: Thursday, March 18, 2021 10:37 AM
To: Ryan Long 
Cc: devel@rtems.org
Subject: Re: [PATCH] pwdgrp.c: Changed assert to void to fix runtime issues 
(CID #1399781)

Ignoring the first line of commit issue...

On Thu, Mar 18, 2021 at 8:29 AM Ryan Long  wrote:
>
> Changed the _Assert_unused_value_equals macro to just a void due to 
> /etc having already been created by the network stack initialization 
> or an initial filesystem image.

Is there a related ticket?

IMO, the CID can be buried down here in the commit message somewhere.
Practically speaking, and I've said it before, the CIDs are a bit meaningless 
since they are outside our control and sit behind an authentication mechanism.

> ---
>  cpukit/libcsupport/src/pwdgrp.c | 9 -
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/cpukit/libcsupport/src/pwdgrp.c 
> b/cpukit/libcsupport/src/pwdgrp.c index f4a10f7..edc8aff 100644
> --- a/cpukit/libcsupport/src/pwdgrp.c
> +++ b/cpukit/libcsupport/src/pwdgrp.c
> @@ -36,7 +36,6 @@
>  #include 
>
>  #include 
> -#include 
>
>  #include "pwdgrp.h"
>
> @@ -63,13 +62,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.
> +   *
> +   * /etc could be created by the network stack initialization or an initial
> +   * filesystem image. Deliberately ignore the return value.
> */
> -  sc = mkdir("/etc", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | 
> S_IXOTH);
> -  _Assert_Unused_variable_equals(sc, 0);
> +  (void) mkdir("/etc", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | 
> + S_IXOTH);
>
Is it better to ignore the return value, or should there be debug checking of 
errno values? I think the only valid return of -1 would be with errno==EEXIST.

>/*
> *  Initialize /etc/passwd
> --
> 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   >