Skip to content

remove warning due to bad casts#9

Open
YvesKO wants to merge 1 commit intounikraft:stagingfrom
Unikraft-Lyon-Hackaton-Team-3:staging
Open

remove warning due to bad casts#9
YvesKO wants to merge 1 commit intounikraft:stagingfrom
Unikraft-Lyon-Hackaton-Team-3:staging

Conversation

@YvesKO
Copy link
Copy Markdown

@YvesKO YvesKO commented May 15, 2022

This PR is part of the Unikraft Lyon Hackathon.

This warning occured while building app-sqlite :

/home/ubuntu/challenges/sqlite-warnings/libs/lib-pthread-embedded/attributes.c: In function ‘pthread_getattr_np’:
/home/ubuntu/challenges/sqlite-warnings/libs/lib-pthread-embedded/attributes.c:96:13: warning: assignment to ‘struct uk_thread *’ from incompatible pointer type ‘pte_osThreadHandle’ {aka ‘struct pte_thread_data *’} [-Wincompatible-pointer-types]
   96 |  _uk_thread = tp->threadId;
      |             ^
/home/ubuntu/challenges/sqlite-warnings/libs/lib-pthread-embedded/attributes.c: In function ‘pthread_setname_np’:
/home/ubuntu/challenges/sqlite-warnings/libs/lib-pthread-embedded/attributes.c:122:13: warning: assignment to ‘struct uk_thread *’ from incompatible pointer type ‘pte_osThreadHandle’ {aka ‘struct pte_thread_data *’} [-Wincompatible-pointer-types]
  122 |  _uk_thread = tp->threadId;
      |             ^
/home/ubuntu/challenges/sqlite-warnings/libs/lib-pthread-embedded/attributes.c: In function ‘pthread_getname_np’:
/home/ubuntu/challenges/sqlite-warnings/libs/lib-pthread-embedded/attributes.c:142:13: warning: assignment to ‘struct uk_thread *’ from incompatible pointer type ‘pte_osThreadHandle’ {aka ‘struct pte_thread_data *’} [-Wincompatible-pointer-types]
  142 |  _uk_thread = tp->threadId;

You need to cast tp->thread in struct uk_thread * to allow the assignment.

Copy link
Copy Markdown

@ChatrusMagnus ChatrusMagnus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to recreate the bug and the commit remooves the warnings,
but I run the checkpatch.pl on attributes.c and it returned 4 errors and 8 warnings.

The error that are a consequence of this commit are:

ERROR: "(foo*)" should be "(foo *)"
#122: FILE: attributes.c:122:

  •   _uk_thread = (struct uk_thread*) tp->threadId;
    

ERROR: "(foo*)" should be "(foo *)"
#142: FILE: attributes.c:142:

  •   _uk_thread =(struct uk_thread*) tp->threadId;
    

ERROR: spaces required around that '=' (ctx:WxV)
#142: FILE: attributes.c:142:

  •   _uk_thread =(struct uk_thread*) tp->threadId;
    

There is an additional error:

ERROR: space required after that ',' (ctx:VxV)
#148: FILE: attributes.c:148:

  •   sprintf(name,"%s", _uk_thread->name); 
    

Reviewed-by: Federico fe.chatrian@gmail.com

terminal output:

'WARNING: return of an errno should typically be negative (ie: return -EINVAL)
#37: FILE: attributes.c:37:

  •           return EINVAL;
    

WARNING: return of an errno should typically be negative (ie: return -EINVAL)
#45: FILE: attributes.c:45:

  •           return EINVAL;
    

WARNING: return of an errno should typically be negative (ie: return -ENOENT)
#91: FILE: attributes.c:91:

  •           return ENOENT;
    

WARNING: return of an errno should typically be negative (ie: return -EINVAL)
#94: FILE: attributes.c:94:

  •           return EINVAL;
    

WARNING: return of an errno should typically be negative (ie: return -ENOENT)
#120: FILE: attributes.c:120:

  •           return ENOENT;
    

ERROR: "(foo*)" should be "(foo *)"
#122: FILE: attributes.c:122:

  •   _uk_thread = (struct uk_thread*) tp->threadId;
    

WARNING: return of an errno should typically be negative (ie: return -ERANGE)
#126: FILE: attributes.c:126:

  •           return ERANGE;
    

WARNING: return of an errno should typically be negative (ie: return -ENOENT)
#140: FILE: attributes.c:140:

  •           return ENOENT;
    

ERROR: "(foo*)" should be "(foo *)"
#142: FILE: attributes.c:142:

  •   _uk_thread =(struct uk_thread*) tp->threadId;
    

ERROR: spaces required around that '=' (ctx:WxV)
#142: FILE: attributes.c:142:

  •   _uk_thread =(struct uk_thread*) tp->threadId;
                 ^
    

WARNING: return of an errno should typically be negative (ie: return -ERANGE)
#146: FILE: attributes.c:146:

  •           return ERANGE;
    

ERROR: space required after that ',' (ctx:VxV)
#148: FILE: attributes.c:148:

  •   sprintf(name,"%s", _uk_thread->name);
                  ^
    

total: 4 errors, 8 warnings, 151 lines checked
'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants