Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
spbro
OpenXG-RAN
Commits
9e643575
Commit
9e643575
authored
Aug 26, 2024
by
Guido Casati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap multi-statement macros ENCODE_U8() and ENCODE_U32() in do { ... } while (0) statements
parent
bac4f798
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
openair3/NAS/COMMON/UTIL/TLVEncoder.h
openair3/NAS/COMMON/UTIL/TLVEncoder.h
+8
-6
No files found.
openair3/NAS/COMMON/UTIL/TLVEncoder.h
View file @
9e643575
...
...
@@ -24,9 +24,11 @@
#include <arpa/inet.h> // htonl, htons
#define ENCODE_U8(buffer, value, size) \
*(uint8_t*)(buffer) = value; \
size += sizeof(uint8_t)
#define ENCODE_U8(buffer, value, size) \
do { \
*(uint8_t*)(buffer) = value; \
size += sizeof(uint8_t); \
} while (0)
/* Safely encodes a 16-bit value into a buffer, handling
misalignment by memcpy 2 bytes to buffer in network
...
...
@@ -49,11 +51,11 @@
} while (0)
#define ENCODE_U32(buffer, value, size) \
{
\
do {
\
uint32_t tmp = htonl(value); \
memcpy(buffer, &tmp, sizeof(tmp)); \
}
\
size += sizeof(uint32_t
)
size += sizeof(uint32_t);
\
} while (0
)
#define IES_ENCODE_U8(buffer, encoded, value) \
ENCODE_U8(buffer + encoded, value, encoded)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment