ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@altlinux.org>
To: ALT Devel discussion list <devel@lists.altlinux.org>
Subject: Re: [devel] Что это? Переопределение функций?
Date: Mon, 31 Jul 2017 22:30:40 +0300
Message-ID: <20170731193039.GA9100@altlinux.org> (raw)
In-Reply-To: <382cf736-040a-ea18-4404-8835b2e26ec1@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1540 bytes --]

On Mon, Jul 31, 2017 at 09:56:02PM +0300, Дмитрий Ханжин wrote:
> 31.07.2017 13:52, Dmitry V. Levin пишет:
> > Hi,
> > 
> > Текущее состояние по добавлению strlcpy и strlcat в glibc:
> > https://sourceware.org/ml/libc-alpha/2017-06/msg00703.html
> > На данный момент остался только один человек, препятствующий принятию
> > этого патча.  Ну что же, подождём ещё немного.
> >
> 
> Вот что мне ответили:
> 
> > Thanks for your comment!
> > If we modify the prototype declaration will it then not conflict with other distributions?
> > __THROW is a preprocesor symbol which not all compilers may have?
> > Similar for __nonnull.
> > The declarations we have now originate from OpenBSD/FreeBSD.
> > ALT Linux wants to improve on them and so introduces differences?
> > Does ALT Linux have a preprocessor symbol by which we can identify it?
> > Is there a way we can avoid the ALT Linux declaration from string.h?
> > Could you perhaps attach the output of g++ -E /usr/include/string.h ?
> > What would be harmless is if you add a extern "C" linkage specification.
> > Would that suffice? Probably not.
> > What does the ALT Linux team say?
> > Sorry for all the questions.
> 
> Прокомментируйте, пожалуйста, я так глубоко не интересовался.

Апстрим не в теме, и, судя по коду, не скоро будет в теме.

Попробуйте с приложенным патчем, я его не пробовал компилировать,
но, полагаю, что он поможет.  Не забудьте перегенерить configure.

> Ссылку выше прочитал, но тоже ничего не понял. :-(

Жаль.


-- 
ldv

[-- Attachment #1.2: 0001-Do-not-override-strlcpy-and-strlcat-provided-by-the-.patch --]
[-- Type: text/x-patch, Size: 3122 bytes --]

From 2939af61a1e92f7f03950a57f74abaa5bcd0ac07 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Mon, 31 Jul 2017 19:17:17 +0000
Subject: [PATCH] Do not override strlcpy and strlcat provided by the OS

---
 configure.ac | 2 +-
 src/base.h   | 5 +++++
 src/misc.cc  | 7 +++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index fe9176e..b004fd2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,7 +119,7 @@ if test x$cross_compling != xyes ; then :; AC_FUNC_MALLOC fi
 AC_FUNC_MMAP
 if test x$cross_compling != xyes ; then :; AC_FUNC_REALLOC fi
 AC_FUNC_STRNLEN
-AC_CHECK_FUNCS([dup2 getcwd gethostbyname gethostname gettimeofday mblen memchr memmove memset mkdir nl_langinfo putenv select setlocale socket strcasecmp strchr strcspn strdup strerror strncasecmp strrchr strspn strstr strtol sysinfo uname abort wordexp])
+AC_CHECK_FUNCS([dup2 getcwd gethostbyname gethostname gettimeofday mblen memchr memmove memset mkdir nl_langinfo putenv select setlocale socket strcasecmp strchr strcspn strdup strerror strlcpy strlcat strncasecmp strrchr strspn strstr strtol sysinfo uname abort wordexp])
 AC_CHECK_FUNCS([gettimeofday putenv select socket strtol strtoul basename])
 AC_CHECK_FUNCS([sysctlbyname asprintf])
 AC_CHECK_FUNC([getloadavg],[AC_DEFINE([HAVE_GETLOADAVG2], 1, [getloadavg() is available])])
diff --git a/src/base.h b/src/base.h
index 0df34cc..b76ec69 100644
--- a/src/base.h
+++ b/src/base.h
@@ -1,6 +1,7 @@
 #ifndef __BASE_H
 #define __BASE_H
 
+#include "config.h"
 #include <stddef.h>
 
 #ifndef __GNUC__
@@ -48,10 +49,14 @@ inline T abs(T v) {
 
 /*** String Functions *********************************************************/
 
+#ifndef HAVE_STRLCPY
 /* Prefer this as a safer alternative over strcpy. Return strlen(from). */
 size_t strlcpy(char *dest, const char *from, size_t dest_size);
+#endif
+#ifndef HAVE_STRLCAT
 /* Prefer this over strcat. Return strlen(dest) + strlen(from). */
 size_t strlcat(char *dest, const char *from, size_t dest_size);
+#endif
 
 char *newstr(char const *str);
 char *newstr(char const *str, int len);
diff --git a/src/misc.cc b/src/misc.cc
index b0ac1c9..3a88276 100644
--- a/src/misc.cc
+++ b/src/misc.cc
@@ -447,6 +447,8 @@ void operator delete[](void *p) {
 
 #endif
 
+#ifndef HAVE_STRLCPY
+
 /* Prefer this as a safer alternative over strcpy. Return strlen(from). */
 size_t strlcpy(char *dest, const char *from, size_t dest_size)
 {
@@ -461,6 +463,9 @@ size_t strlcpy(char *dest, const char *from, size_t dest_size)
     while (*in) ++in;
     return in - from;
 }
+#endif
+
+#ifndef HAVE_STRLCAT
 
 /* Prefer this over strcat. Return strlen(dest) + strlen(from). */
 size_t strlcat(char *dest, const char *from, size_t dest_size)
@@ -471,6 +476,8 @@ size_t strlcat(char *dest, const char *from, size_t dest_size)
     return to - dest + strlcpy(to, from, dest_size - (to - dest));
 }
 
+#endif
+
 char *newstr(char const *str) {
     return (str != NULL ? newstr(str, strlen(str)) : NULL);
 }
-- 
ldv

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

  reply	other threads:[~2017-07-31 19:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-30 16:56 Дмитрий Ханжин
2017-07-30 17:00 ` Pavel Vainerman
2017-07-30 18:12   ` Дмитрий Ханжин
2017-07-30 18:57     ` Pavel Vainerman
2017-07-31  5:13       ` Дмитрий Ханжин
2017-07-31  9:58         ` Michael Shigorin
2017-07-31 10:15           ` Konstantin Lepikhov
2017-07-31 10:52             ` Dmitry V. Levin
2017-07-31 18:56               ` Дмитрий Ханжин
2017-07-31 19:30                 ` Dmitry V. Levin [this message]
2017-08-01 17:42                   ` [devel] [thx] " Дмитрий Ханжин

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170731193039.GA9100@altlinux.org \
    --to=ldv@altlinux.org \
    --cc=devel@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git