[Openvpn-devel,v1] buffer: Remove some useless casts on BLAST returns

Message ID 20260818142252.27227-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v1] buffer: Remove some useless casts on BLAST returns |

Commit Message

Gert Doering Aug. 18, 2026, 2:22 p.m. UTC
  From: Frank Lichtenheld <frank@lichtenheld.com>

We can compare to '\0' without having to do casting.

Change-Id: I450568c0307a6372506d115cb389d172472140d4
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1845
---

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/+/1845
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <razvanc@mailbox.org>
  

Patch

diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c
index bf38c68..87d3094 100644
--- a/src/openvpn/buffer.c
+++ b/src/openvpn/buffer.c
@@ -500,7 +500,7 @@ 
 void
 buf_null_terminate(struct buffer *buf)
 {
-    const char *last = (char *)BLAST(buf);
+    const uint8_t *last = BLAST(buf);
     if (last && *last == '\0') /* already terminated? */
     {
         return;
@@ -523,12 +523,12 @@ 
 {
     while (true)
     {
-        const char *last = (char *)BLAST(buf);
+        const uint8_t *last = BLAST(buf);
         if (!last)
         {
             break;
         }
-        if (char_class((unsigned char)*last, CC_CRLF | CC_NULL))
+        if (char_class(*last, CC_CRLF | CC_NULL))
         {
             if (!buf_inc_len(buf, -1))
             {