commit | 7b9b3074a282ba5f38476993dcb47e5fc7e77223 | [log] [tgz] |
---|---|---|
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | Sat Feb 25 05:52:37 2023 +0700 |
committer | laforge <laforge@osmocom.org> | Sat Feb 25 08:15:11 2023 +0000 |
tree | 0feefbc266d124ee34b7311b7083e20a7ae84589 | |
parent | 6b69b554f7622c7025ce620486c0bda9b0db8f4a [diff] |
gsm/{bsslap,bssmap_le}: zero-initialize structs using memset() In the unit tests we're using memcmp() to compare decoding results against the expected results. This is a reasonable approach, but there is a pitfall: not only the struct fields are compared, but also the padding bytes preceding/following them. When using gcc's extension zero-initializer {} or even the standard approved { 0 } zero-initializer, padding bytes are not guaranteed to be zeroed. Even worse, according to [1], the init behavior is inconsistent between gcc and clang and optimization levels. All decoding functions in {bsslap,bssmap_le}.c currently use gcc's extension zero-initializer {}. This is not a problem when building with CC=gcc, but with CC=clang the bssmap_le_test fails due to mismatch of padding bytes in struct lcs_cause_ie: [4] PERFORM LOCATION RESPONSE: ERROR: decoded PDU != encoded PDU [5] PERFORM LOCATION RESPONSE: ERROR: decoded PDU != encoded PDU [6] PERFORM LOCATION ABORT: ERROR: decoded PDU != encoded PDU Out of the known struct initialization methods, only the memset() has consistent behavior and sets all bytes to zero, including the padding ones. Using it fixes the bssmap_le_test for CC=clang. [1] https://interrupt.memfault.com/blog/c-struct-padding-initialization Change-Id: Ib16964b16eb04315efc416164ed46c15b5dc7254 Fixes: OS#5923
This repository contains a set of C-language libraries that form the core infrastructure of many Osmocom Open Source Mobile Communications projects.
Historically, a lot of this code was developed as part of the OpenBSC project, but which are of a more generic nature and thus useful to (at least) other programs that we develop in the sphere of Free Software / Open Source mobile communications.
There is no clear scope of it. We simply move all shared code between the various Osmocom projects in this library to avoid code duplication.
The libosmocore.git repository build multiple libraries:
The official homepage of the project is https://osmocom.org/projects/libosmocore/wiki/Libosmocore
You can clone from the official libosmocore.git repository using
git clone https://gitea.osmocom.org/osmocom/libosmocore
There is a web interface at https://gitea.osmocom.org/osmocom/libosmocore
Doxygen-generated API documentation is generated during the build process, but also available online for each of the sub-libraries at https://ftp.osmocom.org/api/latest/libosmocore/
Discussions related to libosmocore are happening on the openbsc@lists.osmocom.org mailing list, please see https://lists.osmocom.org/mailman/listinfo/openbsc for subscription options and the list archive.
Please observe the Osmocom Mailing List Rules when posting.
Our coding standards are described at https://osmocom.org/projects/cellular-infrastructure/wiki/Coding_standards
We us a gerrit based patch submission/review process for managing contributions. Please see https://osmocom.org/projects/cellular-infrastructure/wiki/Gerrit for more details
The current patch queue for libosmocore can be seen at https://gerrit.osmocom.org/#/q/project:libosmocore+status:open