diff mbox series

Fix DEBUG log color application

Message ID 20201112201428.12299-1-christian.storm@siemens.com
State Changes Requested
Headers show
Series Fix DEBUG log color application | expand

Commit Message

Storm, Christian Nov. 12, 2020, 8:14 p.m. UTC
Commit 656e507 reordered log levels resulting in
the DEBUG logcolor not being applied.

Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 core/swupdate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefano Babic Nov. 12, 2020, 8:25 p.m. UTC | #1
Hi Christian,

On 12.11.20 21:14, Christian Storm wrote:
> Commit 656e507 reordered log levels resulting in
> the DEBUG logcolor not being applied.
> 
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>   core/swupdate.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/core/swupdate.c b/core/swupdate.c
> index 5e5fbaf..3327a29 100644
> --- a/core/swupdate.c
> +++ b/core/swupdate.c
> @@ -564,7 +564,7 @@ static int read_console_settings(void *elem, void __attribute__ ((__unused__)) *
>   	char tmp[SWUPDATE_GENERAL_STRING_SIZE] = "";
>   	int i;
>   
> -	for (i = ERRORLEVEL; i <= TRACELEVEL; i++) {
> +	for (i = ERRORLEVEL; i <= DEBUGLEVEL; i++) {

The error here is that the loop uses one of the defined levels instead 
of using LOGLASTLEVEL.

Stefano

>   		memset(tmp, 0, sizeof(tmp));
>   		GET_FIELD_STRING(LIBCFG_PARSER, elem, loglevnames[i], tmp);
>   		if (tmp[0] != '\0')
>
Storm, Christian Nov. 13, 2020, 9:49 a.m. UTC | #2
Hi Stefano,

> > Commit 656e507 reordered log levels resulting in
> > the DEBUG logcolor not being applied.
> > 
> > Signed-off-by: Christian Storm <christian.storm@siemens.com>
> > ---
> >   core/swupdate.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/core/swupdate.c b/core/swupdate.c
> > index 5e5fbaf..3327a29 100644
> > --- a/core/swupdate.c
> > +++ b/core/swupdate.c
> > @@ -564,7 +564,7 @@ static int read_console_settings(void *elem, void __attribute__ ((__unused__)) *
> >   	char tmp[SWUPDATE_GENERAL_STRING_SIZE] = "";
> >   	int i;
> > -	for (i = ERRORLEVEL; i <= TRACELEVEL; i++) {
> > +	for (i = ERRORLEVEL; i <= DEBUGLEVEL; i++) {
> 
> The error here is that the loop uses one of the defined levels instead of
> using LOGLASTLEVEL.

In notifier_set_color() there's
  if (level < ERRORLEVEL ...
so the bounds check for this is still not reorder-proof.
Anyway, I'll send a V2 for this issue.


Kind regards,
   Christian
Stefano Babic Nov. 13, 2020, 10:27 a.m. UTC | #3
On 13.11.20 10:49, Christian Storm wrote:
> Hi Stefano,
> 
>>> Commit 656e507 reordered log levels resulting in
>>> the DEBUG logcolor not being applied.
>>>
>>> Signed-off-by: Christian Storm <christian.storm@siemens.com>
>>> ---
>>>   core/swupdate.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/core/swupdate.c b/core/swupdate.c
>>> index 5e5fbaf..3327a29 100644
>>> --- a/core/swupdate.c
>>> +++ b/core/swupdate.c
>>> @@ -564,7 +564,7 @@ static int read_console_settings(void *elem, void __attribute__ ((__unused__)) *
>>>   	char tmp[SWUPDATE_GENERAL_STRING_SIZE] = "";
>>>   	int i;
>>> -	for (i = ERRORLEVEL; i <= TRACELEVEL; i++) {
>>> +	for (i = ERRORLEVEL; i <= DEBUGLEVEL; i++) {
>>
>> The error here is that the loop uses one of the defined levels instead of
>> using LOGLASTLEVEL.
> 
> In notifier_set_color() there's
>   if (level < ERRORLEVEL ...
> so the bounds check for this is still not reorder-proof.

mmmhhh...you're right, there is space for improvement. The issue above
had not to happen if I had written the loop in the right way...

> Anyway, I'll send a V2 for this issue.

I'll apply as soon as I got it.

Thanks,
Stefano

> 
> 
> Kind regards,
>    Christian
>
diff mbox series

Patch

diff --git a/core/swupdate.c b/core/swupdate.c
index 5e5fbaf..3327a29 100644
--- a/core/swupdate.c
+++ b/core/swupdate.c
@@ -564,7 +564,7 @@  static int read_console_settings(void *elem, void __attribute__ ((__unused__)) *
 	char tmp[SWUPDATE_GENERAL_STRING_SIZE] = "";
 	int i;
 
-	for (i = ERRORLEVEL; i <= TRACELEVEL; i++) {
+	for (i = ERRORLEVEL; i <= DEBUGLEVEL; i++) {
 		memset(tmp, 0, sizeof(tmp));
 		GET_FIELD_STRING(LIBCFG_PARSER, elem, loglevnames[i], tmp);
 		if (tmp[0] != '\0')