Skip to content

Commit b52b3c6

Browse files
committed
Use Attach brace style; add ConstStrLen
Switch .clang-format BreakBeforeBraces from Allman to Attach. Update utils_port.h header comment (file name) and extend copyright year range. Add new common/utils/utils_string.h which provides a constexpr common::ConstStrLen for computing C-string lengths at compile time, with include guards and necessary includes.
1 parent cf94a4b commit b52b3c6

3 files changed

Lines changed: 47 additions & 3 deletions

File tree

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ AllowShortFunctionsOnASingleLine: Inline
1414
AllowShortIfStatementsOnASingleLine: true
1515
AllowShortLoopsOnASingleLine: true
1616

17-
BreakBeforeBraces: Allman
17+
BreakBeforeBraces: Attach
1818

1919
DerivePointerAlignment: false
2020

common/include/common/utils/utils_port.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* @file dmxnode_utils.h
2+
* @file utils_port.h
33
*
44
*/
5-
/* Copyright (C) 2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2025-2026 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @file utils_string.h
3+
*
4+
*/
5+
/* Copyright (C) 2026 by Arjan van Vught mailto:info@gd32-dmx.org
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
26+
#ifndef COMMON_UTILS_UTILS_STRING_H_
27+
#define COMMON_UTILS_UTILS_STRING_H_
28+
29+
#include <cstdint>
30+
31+
namespace common
32+
{
33+
constexpr uint32_t ConstStrLen(const char* s)
34+
{
35+
uint32_t len = 0;
36+
while (s[len] != '\0')
37+
{
38+
++len;
39+
}
40+
return len;
41+
}
42+
} // namespace common
43+
44+
#endif // COMMON_UTILS_UTILS_STRING_H_

0 commit comments

Comments
 (0)