fw: Safer memory functions + asserts

Introduce memcpy_s() and wordcpy_s() that takes the destination buffer
size as an argument. Use assert() which aborts our program to an
eternal loop if we hit problems.

Sprinkle asserts elsewhere as well.

Signed-off-by: Daniel Lublin <daniel@lublin.se>
This commit is contained in:
Michael Cardell Widerkrantz 2023-02-27 17:00:23 +01:00 committed by Daniel Lublin
parent f386cec1ed
commit ccc3b16569
No known key found for this signature in database
GPG key ID: 75BD0FEB8D3E7830
7 changed files with 81 additions and 23 deletions

View file

@ -0,0 +1,16 @@
/*
* Copyright (C) 2022, 2023 - Tillitis AB
* SPDX-License-Identifier: GPL-2.0-only
*/
#ifndef ASSERT_H
#define ASSERT_H
#define assert(expr) \
((expr) ? (void)(0) \
: __assert_fail(#expr, __FILE__, __LINE__, __func__))
void __assert_fail(const char *__assertion, const char *__file,
unsigned int __line, const char *__function);
#endif