Coverage Report

Created: 2026-08-31 06:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/FreeRDP/winpr/libwinpr/path/include/PathCchAddSeparator.h
Line
Count
Source
1
2
/*
3
#define DEFINE_UNICODE    FALSE
4
#define CUR_PATH_SEPARATOR_CHR  '\\'
5
#define PATH_CCH_ADD_SEPARATOR  PathCchAddBackslashA
6
*/
7
8
#if DEFINE_UNICODE
9
10
HRESULT PATH_CCH_ADD_SEPARATOR(PWSTR pszPath, size_t cchPath)
11
0
{
12
0
  WINPR_ASSERT(pszPath || (cchPath == 0));
13
0
  if (!pszPath)
14
0
    return S_OK;
15
16
0
  const size_t pszPathLength = _wcsnlen(pszPath, cchPath);
17
0
  if (pszPathLength < 1)
18
0
    return S_OK;
19
20
0
  if (pszPath[pszPathLength - 1] == CUR_PATH_SEPARATOR_CHR)
21
0
    return S_FALSE;
22
23
0
  if (cchPath > (pszPathLength + 1))
24
0
  {
25
0
    pszPath[pszPathLength] = CUR_PATH_SEPARATOR_CHR;
26
0
    pszPath[pszPathLength + 1] = '\0';
27
28
0
    return S_OK;
29
0
  }
30
31
0
  return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
32
0
}
Unexecuted instantiation: PathCchAddBackslashW
Unexecuted instantiation: PathCchAddSlashW
Unexecuted instantiation: PathCchAddSeparatorW
33
34
#else
35
36
HRESULT PATH_CCH_ADD_SEPARATOR(PSTR pszPath, size_t cchPath)
37
0
{
38
0
  WINPR_ASSERT(pszPath || (cchPath == 0));
39
0
  if (!pszPath)
40
0
    return S_OK;
41
42
0
  const size_t pszPathLength = strnlen(pszPath, cchPath);
43
0
  if (pszPathLength < 1)
44
0
    return S_OK;
45
46
0
  if (pszPath[pszPathLength - 1] == CUR_PATH_SEPARATOR_CHR)
47
0
    return S_FALSE;
48
49
0
  if (cchPath > (pszPathLength + 1))
50
0
  {
51
0
    pszPath[pszPathLength] = CUR_PATH_SEPARATOR_CHR;
52
0
    pszPath[pszPathLength + 1] = '\0';
53
54
0
    return S_OK;
55
0
  }
56
57
0
  return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
58
0
}
Unexecuted instantiation: PathCchAddBackslashA
Unexecuted instantiation: PathCchAddSlashA
Unexecuted instantiation: PathCchAddSeparatorA
59
60
#endif
61
62
/*
63
#undef DEFINE_UNICODE
64
#undef CUR_PATH_SEPARATOR_CHR
65
#undef PATH_CCH_ADD_SEPARATOR
66
*/