[libc-commits] [libc] [libc] Fix type signature for strlcpy and strlcat (PR #104643)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Fri Aug 16 14:43:06 PDT 2024


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/104643

Summary:
These should not be const on the destination pointer.


>From 370f560769986249eb24524a3ba4a85762a6e1a6 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Fri, 16 Aug 2024 16:42:02 -0500
Subject: [PATCH] [libc] Fix type signature for strlcpy and strlcat

Summary:
These should not be const on the destination pointer.
---
 libc/newhdrgen/yaml/string.yaml | 4 ++--
 libc/spec/bsd_ext.td            | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libc/newhdrgen/yaml/string.yaml b/libc/newhdrgen/yaml/string.yaml
index 387ea9ec4e1422..1d6e64bfb9cf60 100644
--- a/libc/newhdrgen/yaml/string.yaml
+++ b/libc/newhdrgen/yaml/string.yaml
@@ -181,7 +181,7 @@ functions:
       - BSDExtensions
     return_type: size_t
     arguments:
-      - type: const char *__restrict
+      - type: char *__restrict
       - type: const char *__restrict
       - type: size_t
   - name: strlcpy
@@ -189,7 +189,7 @@ functions:
       - BSDExtensions
     return_type: size_t
     arguments:
-      - type: const char *__restrict
+      - type: char *__restrict
       - type: const char *__restrict
       - type: size_t
   - name: strlen
diff --git a/libc/spec/bsd_ext.td b/libc/spec/bsd_ext.td
index 4d33313521735e..2b91324e36db9a 100644
--- a/libc/spec/bsd_ext.td
+++ b/libc/spec/bsd_ext.td
@@ -20,12 +20,12 @@ def BsdExtensions : StandardSpec<"BSDExtensions"> {
         FunctionSpec<
             "strlcat",
             RetValSpec<SizeTType>,
-            [ArgSpec<ConstCharRestrictedPtr>, ArgSpec<ConstCharRestrictedPtr>, ArgSpec<SizeTType>]
+            [ArgSpec<CharRestrictedPtr>, ArgSpec<ConstCharRestrictedPtr>, ArgSpec<SizeTType>]
         >,
         FunctionSpec<
             "strlcpy",
             RetValSpec<SizeTType>,
-            [ArgSpec<ConstCharRestrictedPtr>, ArgSpec<ConstCharRestrictedPtr>, ArgSpec<SizeTType>]
+            [ArgSpec<CharRestrictedPtr>, ArgSpec<ConstCharRestrictedPtr>, ArgSpec<SizeTType>]
         >,
         FunctionSpec<
             "strsep",



More information about the libc-commits mailing list