GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_utility_string_length_get.c Lines: 6 6 100.0 %
Date: 2026-03-06 18:57:10 Branches: 2 2 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
/** USBX Component                                                        */
17
/**                                                                       */
18
/**   Utility                                                             */
19
/**                                                                       */
20
/**************************************************************************/
21
/**************************************************************************/
22
23
24
/* Include necessary system files.  */
25
26
#define UX_SOURCE_CODE
27
28
#include "ux_api.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _ux_utility_string_length_get                       PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Chaoqiong Xiao, Microsoft Corporation                               */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function derives the length of a NULL-terminated string.       */
44
/*                                                                        */
45
/*    This function is deprecated, for the possible issue of operating on */
46
/*    a buffer that is not NULL-terminated. As a replacement,             */
47
/*    _ux_utility_string_length_check should be used, where the length of */
48
/*    the buffer is introduced to validate the string by checking for the */
49
/*    NULL-terminator within the buffer length.                           */
50
/*                                                                        */
51
/*  INPUT                                                                 */
52
/*                                                                        */
53
/*    string                                Pointer to string             */
54
/*                                                                        */
55
/*  OUTPUT                                                                */
56
/*                                                                        */
57
/*    length of string                                                    */
58
/*                                                                        */
59
/*  CALLS                                                                 */
60
/*                                                                        */
61
/*    None                                                                */
62
/*                                                                        */
63
/*  CALLED BY                                                             */
64
/*                                                                        */
65
/*    USBX Components                                                     */
66
/*                                                                        */
67
/**************************************************************************/
68
2149
ULONG  _ux_utility_string_length_get(UCHAR *string)
69
{
70
71
2149
ULONG       length =  0;
72
73
    /* Loop to find the length of the string.  */
74
2149
    length =  0;
75
69835
    while (string[length])
76
    {
77
78
        /* Move to next position.  */
79
67686
        length++;
80
    }
81
82
    /* Return length to caller.  */
83
2149
    return(length);
84
}
85