[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] areadlink-with-size: guess a buffer size with 0 size
From: |
Bruno Haible |
Subject: |
Re: [PATCH] areadlink-with-size: guess a buffer size with 0 size |
Date: |
Fri, 19 Jul 2019 05:24:12 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-154-generic; KDE/5.18.0; x86_64; ; ) |
Paul Eggert wrote on 2019-07-06:
> The string length determination can easily be
> avoided, so I installed the attached which does that.
This patch produces GCC warnings about the use of memcpy().
And mine as well, about the use of strlen().
This patch fixes it:
2019-07-19 Bruno Haible <address@hidden>
areadlink-with-size, xgethostname, xgetdomainname: Fix GCC warning.
* lib/areadlink-with-size.c: Include <string.h>.
* lib/areadlinkat-with-size.c: Likewise.
* lib/xgethostname.c: Likewise.
* lib/xgetdomainname.c: Likewise.
diff --git a/lib/areadlink-with-size.c b/lib/areadlink-with-size.c
index ae3c782..95a28b3 100644
--- a/lib/areadlink-with-size.c
+++ b/lib/areadlink-with-size.c
@@ -26,6 +26,7 @@
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#ifndef SSIZE_MAX
diff --git a/lib/areadlinkat-with-size.c b/lib/areadlinkat-with-size.c
index ed46d59..22d39a9 100644
--- a/lib/areadlinkat-with-size.c
+++ b/lib/areadlinkat-with-size.c
@@ -27,6 +27,7 @@
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#if HAVE_READLINKAT
diff --git a/lib/xgetdomainname.c b/lib/xgetdomainname.c
index 65df990..a1accf6 100644
--- a/lib/xgetdomainname.c
+++ b/lib/xgetdomainname.c
@@ -28,6 +28,9 @@
/* Get errno. */
#include <errno.h>
+/* Get strlen. */
+#include <string.h>
+
/* Get free. */
#include <stdlib.h>
diff --git a/lib/xgethostname.c b/lib/xgethostname.c
index 4bcb00f..5b3154a 100644
--- a/lib/xgethostname.c
+++ b/lib/xgethostname.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <errno.h>
+#include <string.h>
#include <unistd.h>
#include "xalloc.h"
- Re: [PATCH] areadlink-with-size: guess a lower bound with 0 size, (continued)