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% 2 / 0 / 2

fx_file_best_effort_allocate.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 /** File */
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_file.h"
30
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _fx_file_best_effort_allocate PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* William E. Lamie, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function attempts to allocate the number of consecutive */
45 /* clusters required to satisfy the user's request. If there are not */
46 /* enough clusters, the largest set of clusters are allocated and */
47 /* linked to the file. If there are no free clusters, an error */
48 /* code is returned to the caller. */
49 /* */
50 /* INPUT */
51 /* */
52 /* file_ptr File control block pointer */
53 /* size Number of bytes to allocate */
54 /* actual_size_allocated Number of bytes allocated */
55 /* */
56 /* OUTPUT */
57 /* */
58 /* return status */
59 /* */
60 /* CALLS */
61 /* */
62 /* _fx_file_extended_best_effort_allocate */
63 /* Allocate the largest set of */
64 /* clusters */
65 /* */
66 /* CALLED BY */
67 /* */
68 /* Application Code */
69 /* */
70 /**************************************************************************/
71 70 UINT _fx_file_best_effort_allocate(FX_FILE *file_ptr, ULONG size, ULONG *actual_size_allocated)
72 {
73
74 UINT status;
75 ULONG64 temp_actual_size_allocated;
76
77 /* Call actual best effort file allocate service. */
78 70 status = _fx_file_extended_best_effort_allocate(file_ptr, (ULONG64)size, &temp_actual_size_allocated);
79
80 /* Check status. */
81
2/2
✓ Branch 3 → 4 taken 9 times.
✓ Branch 3 → 5 taken 9 times.
18 if (status == FX_SUCCESS)
82 {
83 9 *actual_size_allocated = (ULONG)temp_actual_size_allocated;
84 }
85
86 /* Return status to the caller. */
87 18 return(status);
88 }
89
90