Skip to content

Commit dd1524c

Browse files
d12fkcron2
authored andcommitted
iservice: rename one_glyph to glyph_size
Throughout the function variables which deal with byte counts have a _size postfix. one_glyph is the number of bytes in one character. Reading the code is easier and more consistent this way. Change-Id: I69a6ab59d995fb4a511f57c8535b5ffa4048673c Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net> Acked-by: Gert Doering <gert@greenie.muc.de> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1398 Message-Id: <20251124170055.16034-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34642.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
1 parent dc5baf8 commit dd1524c

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

src/openvpnserv/interactive.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,22 +2156,22 @@ GetItfDnsDomains(HKEY itf, PCWSTR search_domains, PWSTR domains, PDWORD size)
21562156

21572157
LSTATUS err = ERROR_FILE_NOT_FOUND;
21582158
const DWORD buf_size = *size;
2159-
const size_t one_glyph = sizeof(*domains);
2159+
const size_t glyph_size = sizeof(*domains);
21602160
PWSTR values[] = { L"SearchList", L"Domain", L"DhcpDomainSearchList", L"DhcpDomain", NULL };
21612161

21622162
for (int i = 0; values[i]; i++)
21632163
{
21642164
*size = buf_size;
21652165
err = RegGetValueW(itf, NULL, values[i], RRF_RT_REG_SZ, NULL, (PBYTE)domains, size);
2166-
if (!err && *size > one_glyph && domains[(*size / one_glyph) - 1] == '\0' && wcschr(domains, '.'))
2166+
if (!err && *size > glyph_size && domains[(*size / glyph_size) - 1] == '\0' && wcschr(domains, '.'))
21672167
{
21682168
/*
21692169
* Found domain(s), now convert them:
21702170
* - prefix each domain with a dot
21712171
* - convert comma separated list to MULTI_SZ
21722172
*/
21732173
PWCHAR pos = domains;
2174-
const DWORD buf_len = buf_size / one_glyph;
2174+
const DWORD buf_len = buf_size / glyph_size;
21752175
while (TRUE)
21762176
{
21772177
/* Terminate the domain at the next comma */
@@ -2182,8 +2182,8 @@ GetItfDnsDomains(HKEY itf, PCWSTR search_domains, PWSTR domains, PDWORD size)
21822182
}
21832183

21842184
size_t domain_len = wcslen(pos);
2185-
size_t domain_size = domain_len * one_glyph;
2186-
size_t converted_size = (pos - domains) * one_glyph;
2185+
size_t domain_size = domain_len * glyph_size;
2186+
size_t converted_size = (pos - domains) * glyph_size;
21872187

21882188
/* Ignore itf domains which match a pushed search domain */
21892189
if (ListContainsDomain(search_domains, pos, domain_len))
@@ -2192,7 +2192,7 @@ GetItfDnsDomains(HKEY itf, PCWSTR search_domains, PWSTR domains, PDWORD size)
21922192
{
21932193
/* Overwrite the ignored domain with remaining one(s) */
21942194
memmove(pos, comma + 1, buf_size - converted_size);
2195-
*size -= domain_size + one_glyph;
2195+
*size -= domain_size + glyph_size;
21962196
continue;
21972197
}
21982198
else
@@ -2206,31 +2206,31 @@ GetItfDnsDomains(HKEY itf, PCWSTR search_domains, PWSTR domains, PDWORD size)
22062206

22072207
/* Add space for the leading dot */
22082208
domain_len += 1;
2209-
domain_size += one_glyph;
2209+
domain_size += glyph_size;
22102210

22112211
/* Space for the terminating zeros */
2212-
size_t extra_size = 2 * one_glyph;
2212+
size_t extra_size = 2 * glyph_size;
22132213

22142214
/* Check for enough space to convert this domain */
22152215
if (converted_size + domain_size + extra_size > buf_size)
22162216
{
22172217
/* Domain doesn't fit, bad luck if it's the first one */
22182218
*pos = '\0';
2219-
*size = converted_size == 0 ? 0 : converted_size + one_glyph;
2219+
*size = converted_size == 0 ? 0 : converted_size + glyph_size;
22202220
return ERROR_MORE_DATA;
22212221
}
22222222

22232223
/* Prefix domain at pos with the dot */
2224-
memmove(pos + 1, pos, buf_size - converted_size - one_glyph);
2224+
memmove(pos + 1, pos, buf_size - converted_size - glyph_size);
22252225
domains[buf_len - 1] = '\0';
22262226
*pos = '.';
2227-
*size += one_glyph;
2227+
*size += glyph_size;
22282228

22292229
if (!comma)
22302230
{
22312231
/* Conversion is done */
22322232
*(pos + domain_len) = '\0';
2233-
*size += one_glyph;
2233+
*size += glyph_size;
22342234
return NO_ERROR;
22352235
}
22362236

0 commit comments

Comments
 (0)