Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect function parameter types in os-impl-no-select.c #1472

Open
samuel-krain opened this issue Jul 16, 2024 · 2 comments
Open

Incorrect function parameter types in os-impl-no-select.c #1472

samuel-krain opened this issue Jul 16, 2024 · 2 comments
Assignees
Labels
CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB)

Comments

@samuel-krain
Copy link

Describe the bug
The file .../portable/os-impl-no-select has two functions, OS_SelectSingle_Impl() and OS_SelectMultiple_Impl(). These both have the final parameter int32 msecs, which does not match the header definitions in os-shared-select.h where the final parameter is instead OS_time_t abs_timeout.

As a result, there is a compiler error when the file os-impl-no-select is compiled.

Note: files are only compiled when using RTEMS OS with libnetworking library disabled.

To Reproduce
Steps to reproduce the behavior:

  1. Clone OSAL repo into empty directory

  2. Add the rtems6 toolchain file from CFE Repo

  3. Modify toolchain file:

    1. Modify path to relevant RTEMS6 compiler tools
    2. Set CMAKE_SYSTEM_VERSION to 6
    3. Select pc-rtems BSP
    4. Select i386/pc686 architecture
  4. Add the RTEMS.cmake platform module from the PSP repo in ./Platform

  5. Add the following lines before project() in top-level CMakeLists.txt:

list(APPEND CMAKE_MODULE_PATH "$ENV{HOME}/<path-to-project>")
include(Platform/RTEMS)
  1. Run the following commands:
mkdir build && cd build
cmake \
    -DCMAKE_BUILD_TYPE=debug \
    -DENABLE_UNIT_TESTS=true \
    -DOSAL_CONFIG_DEBUG_PERMISSIVE_MODE=true \
    -DOSAL_CONFIG_INCLUDE_NETWORK=FALSE \
    -DCMAKE_TOOLCHAIN_FILE="path/to/toolchain-pc686-rtems.cmake" \
    ../osal
make
  1. See following error:
...
[ 18%] Building C object osal/rtems_impl/CMakeFiles/osal_rtems_impl.dir/src/os-impl-loader.c.o
[ 19%] Building C object osal/rtems_impl/CMakeFiles/osal_rtems_impl.dir/__/portable/os-impl-posix-dl-symtab.c.o
[ 20%] Building C object osal/rtems_impl/CMakeFiles/osal_rtems_impl.dir/__/portable/os-impl-no-network.c.o
[ 21%] Building C object osal/rtems_impl/CMakeFiles/osal_rtems_impl.dir/__/portable/os-impl-no-sockets.c.o
[ 21%] Building C object osal/rtems_impl/CMakeFiles/osal_rtems_impl.dir/__/portable/os-impl-no-select.c.o
/<path>/osal/src/os/portable/os-impl-no-select.c:60:7: error: conflicting types for 'OS_SelectSingle_Impl'; have 'int32(const OS_object_token_t *, uint32 *, int32)' {aka 'int(const struct OS_object_token *, unsigned int *, int)'}
   60 | int32 OS_SelectSingle_Impl(const OS_object_token_t *token, uint32 *SelectFlags, int32 msecs)
      |       ^~~~~~~~~~~~~~~~~~~~
In file included from /<path>/osal/src/os/portable/os-impl-no-select.c:32:
/<path>/osal/src/os/shared/inc/os-shared-select.h:52:7: note: previous declaration of 'OS_SelectSingle_Impl' with type 'int32(const OS_object_token_t *, uint32 *, OS_time_t)' {aka 'int(const struct OS_object_token *, unsigned int *, OS_time_t)'}
   52 | int32 OS_SelectSingle_Impl(const OS_object_token_t *token, uint32 *SelectFlags, OS_time_t abs_timeout);
      |       ^~~~~~~~~~~~~~~~~~~~
/<path>/osal/src/os/portable/os-impl-no-select.c:71:7: error: conflicting types for 'OS_SelectMultiple_Impl'; have 'int32(OS_FdSet *, OS_FdSet *, int32)' {aka 'int(OS_FdSet *, OS_FdSet *, int)'}
   71 | int32 OS_SelectMultiple_Impl(OS_FdSet *ReadSet, OS_FdSet *WriteSet, int32 msecs)
      |       ^~~~~~~~~~~~~~~~~~~~~~
/<path>/osal/src/os/shared/inc/os-shared-select.h:75:7: note: previous declaration of 'OS_SelectMultiple_Impl' with type 'int32(OS_FdSet *, OS_FdSet *, OS_time_t)' {aka 'int(OS_FdSet *, OS_FdSet *, OS_time_t)'}
   75 | int32 OS_SelectMultiple_Impl(OS_FdSet *ReadSet, OS_FdSet *WriteSet, OS_time_t abs_timeout);
      |       ^~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [osal/rtems_impl/CMakeFiles/osal_rtems_impl.dir/build.make:426: osal/rtems_impl/CMakeFiles/osal_rtems_impl.dir/__/portable/os-impl-no-select.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:386: osal/rtems_impl/CMakeFiles/osal_rtems_impl.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Expected behavior
Compilation without errors.

Code snips
os-impl-no-select.c:

/****************************************************************************************
                                    INCLUDE FILES
 ***************************************************************************************/

#include <osapi.h>
#include "os-shared-select.h"

...

/*----------------------------------------------------------------
 *
 *  Purpose: Implemented per internal OSAL API
 *           See prototype for argument/return detail
 *
 *-----------------------------------------------------------------*/
int32 OS_SelectSingle_Impl(const OS_object_token_t *token, uint32 *SelectFlags, int32 msecs)
{
    return OS_ERR_NOT_IMPLEMENTED;
}

/*----------------------------------------------------------------
 *
 *  Purpose: Implemented per internal OSAL API
 *           See prototype for argument/return detail
 *
 *-----------------------------------------------------------------*/
int32 OS_SelectMultiple_Impl(OS_FdSet *ReadSet, OS_FdSet *WriteSet, int32 msecs)
{
    return OS_ERR_NOT_IMPLEMENTED;
}

os-shared-select.h:

...
int32 OS_SelectSingle_Impl(const OS_object_token_t *token, uint32 *SelectFlags, OS_time_t abs_timeout);
...
int32 OS_SelectMultiple_Impl(OS_FdSet *ReadSet, OS_FdSet *WriteSet, OS_time_t abs_timeout);
...

Additional Context

OSAL does not appear to be compatible with libbsp library which replaces libnetworking in RTEMS6. Therefore, networking is more likely to be disabled.

System observed on:

  • Hardware:

    Component Value
    processor 12th Gen Intel(R) Core(TM) i7-12700K
    memory 64GiB System memory
    display GA104 [GeForce RTX 3060 Ti Lite Hash Rate]
  • OS: Ubuntu 22.04.4 LTS (kernel 6.5.0)

  • Versions: OSAL commit d6412df in main (latest as of 07-16-24)

Reporter Info
Samuel Krain

@samuel-krain
Copy link
Author

This appears to be a very easy fix by changing the final parameter to match the header file - might make a good first issue?

@skliper
Copy link
Contributor

skliper commented Jul 16, 2024

@dzbaker - is it possible to prioritize this one along w/ a CI review as to how this wasn't caught (and confirm there isn't a systematic issue)?

@chillfig chillfig added the CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB) label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB)
Projects
None yet
Development

No branches or pull requests

4 participants