Change in openvpn[master]: iservice: rename one_glyph to glyph_size
A message that is not in the archive (sent off-list or not yet received): gerrit.1763928247000.I69a6ab59d995fb4a511f57c8535b5ffa4048673c@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1398?usp=email
to review the following change.
Change subject: iservice: rename one_glyph to glyph_size
......................................................................
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.
---
M src/openvpnserv/interactive.c
1 file changed, 12 insertions(+), 12 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/98/1398/1
src/openvpnserv/interactive.c +12 -12
@@ -2156,14 +2156,14 @@LSTATUS err =ERROR_FILE_NOT_FOUND ;const DWORD buf_size = *size; -const size_t one_glyph =sizeof (*domains); +const size_t glyph_size =sizeof (*domains);PWSTR values[] = {L"SearchList" ,L"Domain" ,L"DhcpDomainSearchList" ,L"DhcpDomain" ,NULL };for (int i =0 ; values[i]; i++) { *size = buf_size; err =RegGetValueW (itf,NULL , values[i],RRF_RT_REG_SZ ,NULL , (PBYTE )domains, size); -if (!err && *size > one_glyph && domains[(*size / one_glyph) -1 ] =='\0' &&wcschr (domains,'.' )) +if (!err && *size > glyph_size && domains[(*size / glyph_size) -1 ] =='\0' &&wcschr (domains,'.' )) {/* * Found domain(s), now convert them:
@@ -2171,7 +2171,7 @@* - convert comma separated list to MULTI_SZ */ PWCHAR pos = domains; -const DWORD buf_len = buf_size / one_glyph; +const DWORD buf_len = buf_size / glyph_size;while (TRUE) {/* Terminate the domain at the next comma */
@@ -2182,8 +2182,8 @@ }size_t domain_len =wcslen (pos); -size_t domain_size = domain_len * one_glyph; -size_t converted_size = (pos - domains) * one_glyph; +size_t domain_size = domain_len * glyph_size; +size_t converted_size = (pos - domains) * glyph_size;/* Ignore itf domains which match a pushed search domain */ if (ListContainsDomain (search_domains, pos, domain_len))
@@ -2192,7 +2192,7 @@ {/* Overwrite the ignored domain with remaining one(s) */ memmove (pos, comma +1 , buf_size - converted_size); - *size -= domain_size + one_glyph; + *size -= domain_size + glyph_size;continue ; } else
@@ -2206,31 +2206,31 @@/* Add space for the leading dot */ domain_len +=1 ; - domain_size += one_glyph; + domain_size += glyph_size;/* Space for the terminating zeros */ -size_t extra_size =2 * one_glyph; +size_t extra_size =2 * glyph_size;/* Check for enough space to convert this domain */ if (converted_size + domain_size + extra_size > buf_size) {/* Domain doesn't fit, bad luck if it's the first one */ *pos ='\0' ; - *size = converted_size ==0 ?0 : converted_size + one_glyph; + *size = converted_size ==0 ?0 : converted_size + glyph_size;return ERROR_MORE_DATA ; }/* Prefix domain at pos with the dot */ -memmove (pos +1 , pos, buf_size - converted_size - one_glyph); +memmove (pos +1 , pos, buf_size - converted_size - glyph_size); domains[buf_len -1 ] ='\0' ; *pos ='.' ; - *size += one_glyph; + *size += glyph_size;if (!comma) {/* Conversion is done */ *(pos + domain_len) ='\0' ; - *size += one_glyph; + *size += glyph_size;return NO_ERROR ; }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1398?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I69a6ab59d995fb4a511f57c8535b5ffa4048673c
Gerrit-Change-Number: 1398
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: d12fk, plaisthos.
cron2 has posted comments on this change by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/1398?usp=email )
Change subject: iservice: rename one_glyph to glyph_size
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1398?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I69a6ab59d995fb4a511f57c8535b5ffa4048673c
Gerrit-Change-Number: 1398
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Mon, 24 Nov 2025 17:00:37 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH 1/1 iservice: rename one_glyph to glyph_size
In reply to a message not in the archiveFrom: Heiko Hund <[email protected]...>
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.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1398
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1398
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpnserv/interactive.c +12 -12
@@ -2156,14 +2156,14 @@LSTATUS err =ERROR_FILE_NOT_FOUND ;const DWORD buf_size = *size; -const size_t one_glyph =sizeof (*domains); +const size_t glyph_size =sizeof (*domains);PWSTR values[] = {L"SearchList" ,L"Domain" ,L"DhcpDomainSearchList" ,L"DhcpDomain" ,NULL };for (int i =0 ; values[i]; i++) { *size = buf_size; err =RegGetValueW (itf,NULL , values[i],RRF_RT_REG_SZ ,NULL , (PBYTE )domains, size); -if (!err && *size > one_glyph && domains[(*size / one_glyph) -1 ] =='\0' &&wcschr (domains,'.' )) +if (!err && *size > glyph_size && domains[(*size / glyph_size) -1 ] =='\0' &&wcschr (domains,'.' )) {/* * Found domain(s), now convert them:
@@ -2171,7 +2171,7 @@* - convert comma separated list to MULTI_SZ */ PWCHAR pos = domains; -const DWORD buf_len = buf_size / one_glyph; +const DWORD buf_len = buf_size / glyph_size;while (TRUE) {/* Terminate the domain at the next comma */
@@ -2182,8 +2182,8 @@ }size_t domain_len =wcslen (pos); -size_t domain_size = domain_len * one_glyph; -size_t converted_size = (pos - domains) * one_glyph; +size_t domain_size = domain_len * glyph_size; +size_t converted_size = (pos - domains) * glyph_size;/* Ignore itf domains which match a pushed search domain */ if (ListContainsDomain (search_domains, pos, domain_len))
@@ -2192,7 +2192,7 @@ {/* Overwrite the ignored domain with remaining one(s) */ memmove (pos, comma +1 , buf_size - converted_size); - *size -= domain_size + one_glyph; + *size -= domain_size + glyph_size;continue ; } else
@@ -2206,31 +2206,31 @@/* Add space for the leading dot */ domain_len +=1 ; - domain_size += one_glyph; + domain_size += glyph_size;/* Space for the terminating zeros */ -size_t extra_size =2 * one_glyph; +size_t extra_size =2 * glyph_size;/* Check for enough space to convert this domain */ if (converted_size + domain_size + extra_size > buf_size) {/* Domain doesn't fit, bad luck if it's the first one */ *pos ='\0' ; - *size = converted_size ==0 ?0 : converted_size + one_glyph; + *size = converted_size ==0 ?0 : converted_size + glyph_size;return ERROR_MORE_DATA ; }/* Prefix domain at pos with the dot */ -memmove (pos +1 , pos, buf_size - converted_size - one_glyph); +memmove (pos +1 , pos, buf_size - converted_size - glyph_size); domains[buf_len -1 ] ='\0' ; *pos ='.' ; - *size += one_glyph; + *size += glyph_size;if (!comma) {/* Conversion is done */ *(pos + domain_len) ='\0' ; - *size += one_glyph; + *size += glyph_size;return NO_ERROR ; }
[Openvpn-devel] [PATCH applied] Re: iservice: rename one_glyph to glyph_size
This is actually not a bugfix but a readability improvement, and as such, very welcome :-) - now everything in that function that deals with bytes is "_size", and everything that deals in wide characters is "_len".
Build tested on Ubuntu/MinGW ("just to be sure I haven't overlooked anything").
Your patch has been applied to the master branch.
commit dd1524c0bd7c7358b39da2fb4911076054736e0a
Author: Heiko Hund Date: Mon Nov 24 18:00:50 2025 +0100
iservice: rename one_glyph to glyph_size
Signed-off-by: Heiko Hund <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1398
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34642.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#2) to the change originally created by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/1398?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: iservice: rename one_glyph to glyph_size
......................................................................
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.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1398
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34642.html
---
M src/openvpnserv/interactive.c
1 file changed, 12 insertions(+), 12 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/98/1398/2
src/openvpnserv/interactive.c +12 -12
@@ -2156,14 +2156,14 @@LSTATUS err =ERROR_FILE_NOT_FOUND ;const DWORD buf_size = *size; -const size_t one_glyph =sizeof (*domains); +const size_t glyph_size =sizeof (*domains);PWSTR values[] = {L"SearchList" ,L"Domain" ,L"DhcpDomainSearchList" ,L"DhcpDomain" ,NULL };for (int i =0 ; values[i]; i++) { *size = buf_size; err =RegGetValueW (itf,NULL , values[i],RRF_RT_REG_SZ ,NULL , (PBYTE )domains, size); -if (!err && *size > one_glyph && domains[(*size / one_glyph) -1 ] =='\0' &&wcschr (domains,'.' )) +if (!err && *size > glyph_size && domains[(*size / glyph_size) -1 ] =='\0' &&wcschr (domains,'.' )) {/* * Found domain(s), now convert them:
@@ -2171,7 +2171,7 @@* - convert comma separated list to MULTI_SZ */ PWCHAR pos = domains; -const DWORD buf_len = buf_size / one_glyph; +const DWORD buf_len = buf_size / glyph_size;while (TRUE) {/* Terminate the domain at the next comma */
@@ -2182,8 +2182,8 @@ }size_t domain_len =wcslen (pos); -size_t domain_size = domain_len * one_glyph; -size_t converted_size = (pos - domains) * one_glyph; +size_t domain_size = domain_len * glyph_size; +size_t converted_size = (pos - domains) * glyph_size;/* Ignore itf domains which match a pushed search domain */ if (ListContainsDomain (search_domains, pos, domain_len))
@@ -2192,7 +2192,7 @@ {/* Overwrite the ignored domain with remaining one(s) */ memmove (pos, comma +1 , buf_size - converted_size); - *size -= domain_size + one_glyph; + *size -= domain_size + glyph_size;continue ; } else
@@ -2206,31 +2206,31 @@/* Add space for the leading dot */ domain_len +=1 ; - domain_size += one_glyph; + domain_size += glyph_size;/* Space for the terminating zeros */ -size_t extra_size =2 * one_glyph; +size_t extra_size =2 * glyph_size;/* Check for enough space to convert this domain */ if (converted_size + domain_size + extra_size > buf_size) {/* Domain doesn't fit, bad luck if it's the first one */ *pos ='\0' ; - *size = converted_size ==0 ?0 : converted_size + one_glyph; + *size = converted_size ==0 ?0 : converted_size + glyph_size;return ERROR_MORE_DATA ; }/* Prefix domain at pos with the dot */ -memmove (pos +1 , pos, buf_size - converted_size - one_glyph); +memmove (pos +1 , pos, buf_size - converted_size - glyph_size); domains[buf_len -1 ] ='\0' ; *pos ='.' ; - *size += one_glyph; + *size += glyph_size;if (!comma) {/* Conversion is done */ *(pos + domain_len) ='\0' ; - *size += one_glyph; + *size += glyph_size;return NO_ERROR ; }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1398?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I69a6ab59d995fb4a511f57c8535b5ffa4048673c
Gerrit-Change-Number: 1398
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1398?usp=email )
Change subject: iservice: rename one_glyph to glyph_size
......................................................................
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.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1398
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34642.html
---
M src/openvpnserv/interactive.c
1 file changed, 12 insertions(+), 12 deletions(-)
src/openvpnserv/interactive.c +12 -12
@@ -2156,14 +2156,14 @@LSTATUS err =ERROR_FILE_NOT_FOUND ;const DWORD buf_size = *size; -const size_t one_glyph =sizeof (*domains); +const size_t glyph_size =sizeof (*domains);PWSTR values[] = {L"SearchList" ,L"Domain" ,L"DhcpDomainSearchList" ,L"DhcpDomain" ,NULL };for (int i =0 ; values[i]; i++) { *size = buf_size; err =RegGetValueW (itf,NULL , values[i],RRF_RT_REG_SZ ,NULL , (PBYTE )domains, size); -if (!err && *size > one_glyph && domains[(*size / one_glyph) -1 ] =='\0' &&wcschr (domains,'.' )) +if (!err && *size > glyph_size && domains[(*size / glyph_size) -1 ] =='\0' &&wcschr (domains,'.' )) {/* * Found domain(s), now convert them:
@@ -2171,7 +2171,7 @@* - convert comma separated list to MULTI_SZ */ PWCHAR pos = domains; -const DWORD buf_len = buf_size / one_glyph; +const DWORD buf_len = buf_size / glyph_size;while (TRUE) {/* Terminate the domain at the next comma */
@@ -2182,8 +2182,8 @@ }size_t domain_len =wcslen (pos); -size_t domain_size = domain_len * one_glyph; -size_t converted_size = (pos - domains) * one_glyph; +size_t domain_size = domain_len * glyph_size; +size_t converted_size = (pos - domains) * glyph_size;/* Ignore itf domains which match a pushed search domain */ if (ListContainsDomain (search_domains, pos, domain_len))
@@ -2192,7 +2192,7 @@ {/* Overwrite the ignored domain with remaining one(s) */ memmove (pos, comma +1 , buf_size - converted_size); - *size -= domain_size + one_glyph; + *size -= domain_size + glyph_size;continue ; } else
@@ -2206,31 +2206,31 @@/* Add space for the leading dot */ domain_len +=1 ; - domain_size += one_glyph; + domain_size += glyph_size;/* Space for the terminating zeros */ -size_t extra_size =2 * one_glyph; +size_t extra_size =2 * glyph_size;/* Check for enough space to convert this domain */ if (converted_size + domain_size + extra_size > buf_size) {/* Domain doesn't fit, bad luck if it's the first one */ *pos ='\0' ; - *size = converted_size ==0 ?0 : converted_size + one_glyph; + *size = converted_size ==0 ?0 : converted_size + glyph_size;return ERROR_MORE_DATA ; }/* Prefix domain at pos with the dot */ -memmove (pos +1 , pos, buf_size - converted_size - one_glyph); +memmove (pos +1 , pos, buf_size - converted_size - glyph_size); domains[buf_len -1 ] ='\0' ; *pos ='.' ; - *size += one_glyph; + *size += glyph_size;if (!comma) {/* Conversion is done */ *(pos + domain_len) ='\0' ; - *size += one_glyph; + *size += glyph_size;return NO_ERROR ; }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1398?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I69a6ab59d995fb4a511f57c8535b5ffa4048673c
Gerrit-Change-Number: 1398
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>