GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_utility_string_length_get.c Lines: 5 5 100.0 %
Date: 2026-03-06 18:49:02 Branches: 4 4 100.0 %

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
8
UINT  _fx_utility_string_length_get(CHAR *string, UINT max_length)
66
{
67
68
UINT length;
69
70
    /* Initialize length to 0.  */
71
8
    length = 0;
72
73
    /* Loop to calculate the length.  */
74

548
    while (string[length] && (length < max_length))
75
    {
76
77
        /* Increment the length (index).  */
78
540
        length++;
79
    }
80
81
    /* Return length.  */
82
8
    return(length);
83
}
84