GCC Code Coverage Report


Directory: common/src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 5 / 0 / 5
Functions: 100.0% 1 / 0 / 1
Branches: 100.0% 4 / 0 / 4

fx_utility_string_length_get.c
Line Branch Exec Source
1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 * Copyright (c) 2026-present Eclipse ThreadX contributors
4 *
5 * This program and the accompanying materials are made available under the
6 * terms of the MIT License which is available at
7 * https://opensource.org/licenses/MIT.
8 *
9 * SPDX-License-Identifier: MIT
10 **************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** FileX Component */
17 /** */
18 /** Utility */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23 #define FX_SOURCE_CODE
24
25
26 /* Include necessary system files. */
27
28 #include "fx_api.h"
29 #include "fx_utility.h"
30
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _fx_utility_string_length_get PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* William E. Lamie, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function returns length of string up to the maximum length. */
45 /* */
46 /* INPUT */
47 /* */
48 /* string Pointer to string */
49 /* max_length Maximum length which can be */
50 /* returned by function */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* return length of string */
55 /* */
56 /* CALLS */
57 /* */
58 /* None */
59 /* */
60 /* CALLED BY */
61 /* */
62 /* _fx_utility_absolute_path_get Get absolute path */
63 /* */
64 /**************************************************************************/
65 64 UINT _fx_utility_string_length_get(CHAR *string, UINT max_length)
66 {
67
68 UINT length;
69
70 /* Initialize length to 0. */
71 64 length = 0;
72
73 /* Loop to calculate the length. */
74
4/4
✓ Branch 4 → 5 taken 3809 times.
✓ Branch 4 → 6 taken 55 times.
✓ Branch 5 → 3 taken 3800 times.
✓ Branch 5 → 6 taken 9 times.
3864 while (string[length] && (length < max_length))
75 {
76
77 /* Increment the length (index). */
78 3800 length++;
79 }
80
81 /* Return length. */
82 64 return(length);
83 }
84
85