Coverage Report

Created: 2025-07-01 06:46

/src/FreeRDP/winpr/libwinpr/crt/conversion.c
Line
Count
Source (jump to first uncovered line)
1
/**
2
 * WinPR: Windows Portable Runtime
3
 * Data Conversion
4
 *
5
 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
20
#include <winpr/config.h>
21
22
#include <winpr/crt.h>
23
#include <winpr/string.h>
24
25
/* Data Conversion: http://msdn.microsoft.com/en-us/library/0heszx3w/ */
26
27
#ifndef _WIN32
28
29
errno_t _itoa_s(int value, char* buffer, size_t sizeInCharacters, WINPR_ATTR_UNUSED int radix)
30
0
{
31
0
  int length = sprintf_s(NULL, 0, "%d", value);
32
33
0
  if (length < 0)
34
0
    return -1;
35
36
0
  if (sizeInCharacters < (size_t)length)
37
0
    return -1;
38
39
0
  (void)sprintf_s(buffer, WINPR_ASSERTING_INT_CAST(size_t, length + 1), "%d", value);
40
41
0
  return 0;
42
0
}
43
44
#endif