View Issue Details

IDProjectCategoryView StatusLast Update
0000044file[All Projects] Generalpublic2018-10-01 18:48
ReporteranonymousAssigned Tochristos 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version5.34 
Target VersionFixed in Version5.35 
Summary0000044: Obsolete HAVE_SIGNAL_H symbol
DescriptionThe <signal.h> header file is part of the standard C89 headers [1]
and on current systems can be included unconditionally.

Since file requires at least C89 or greater, the HAVE_SIGNAL_H symbol
defined by Autoconf in configure.ac [2] can be ommitted and simplifed.

Refs:
[1] https://port70.net/~nsz/c/c89/c89-draft.html#4.1.2
[2] https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4

Thank you.
Additional InformationPull request has been also opened on GitHub for better overview of the patch needed. https://github.com/file/file/pull/42
TagsNo tags attached.
Attach Tags

Activities

anonymous

2018-09-17 00:26

reporter  

42.patch (2,813 bytes)
From 0425c8e2760ebbb452ed0038c99356b20c945991 Mon Sep 17 00:00:00 2001
From: Peter Kokot <peterkokot@gmail.com>
Date: Mon, 17 Sep 2018 02:22:46 +0200
Subject: [PATCH] Remove HAVE_SIGNAL_H

The `<signal.h>` header file is part of the standard C89 headers [1]
and on current systems can be included unconditionally.

Since file requires at least C89 or greater, the `HAVE_SIGNAL_H` symbol
defined by Autoconf in configure.ac [2] can be ommitted and simplifed.

Refs:
[1] https://port70.net/~nsz/c/c89/c89-draft.html#4.1.2
[2] https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4
---
 configure.ac   |  7 ++-----
 src/compress.c | 12 ++----------
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/configure.ac b/configure.ac
index ab4f6fc21..72d69ed66 100644
--- a/configure.ac
+++ b/configure.ac
@@ -92,15 +92,12 @@ AC_HEADER_MAJOR
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(stdint.h fcntl.h locale.h stdint.h inttypes.h unistd.h)
 AC_CHECK_HEADERS(stddef.h utime.h wchar.h wctype.h limits.h)
-AC_CHECK_HEADERS(getopt.h err.h xlocale.h signal.h)
+AC_CHECK_HEADERS(getopt.h err.h xlocale.h)
 AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
 if test "$enable_zlib" != "no"; then
   AC_CHECK_HEADERS(zlib.h)
 fi
-AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif])
+AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[#include <signal.h>])
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
diff --git a/src/compress.c b/src/compress.c
index 041ba4c6d..bfd45b443 100644
--- a/src/compress.c
+++ b/src/compress.c
@@ -47,12 +47,10 @@ FILE_RCSID("@(#)$File: compress.c,v 1.111 2018/09/11 16:33:21 christos Exp $")
 #include <errno.h>
 #include <ctype.h>
 #include <stdarg.h>
-#ifdef HAVE_SIGNAL_H
 #include <signal.h>
-# ifndef HAVE_SIG_T
+#ifndef HAVE_SIG_T
 typedef void (*sig_t)(int);
-# endif /* HAVE_SIG_T */
-#endif
+#endif /* HAVE_SIG_T */
 #if !defined(__MINGW32__) && !defined(WIN32)
 #include <sys/ioctl.h>
 #endif
@@ -228,16 +226,12 @@ file_zmagic(struct magic_set *ms, const struct buffer *b, const char *name)
 	int fd = b->fd;
 	const unsigned char *buf = b->fbuf;
 	size_t nbytes = b->flen;
-#ifdef HAVE_SIGNAL_H
 	sig_t osigpipe;
-#endif
 
 	if ((ms->flags & MAGIC_COMPRESS) == 0)
 		return 0;
 
-#ifdef HAVE_SIGNAL_H
 	osigpipe = signal(SIGPIPE, SIG_IGN);
-#endif
 	for (i = 0; i < ncompr; i++) {
 		int zm;
 		if (nbytes < compr[i].maglen)
@@ -308,9 +302,7 @@ file_zmagic(struct magic_set *ms, const struct buffer *b, const char *name)
 out:
 	DPRINTF("rv = %d\n", rv);
 
-#ifdef HAVE_SIGNAL_H
 	(void)signal(SIGPIPE, osigpipe);
-#endif
 	free(newbuf);
 	ms->flags |= MAGIC_COMPRESS;
 	DPRINTF("Zmagic returns %d\n", rv);
42.patch (2,813 bytes)

Issue History

Date Modified Username Field Change
2018-09-17 00:26 anonymous New Issue
2018-09-17 00:26 anonymous File Added: 42.patch
2018-10-01 18:48 christos Assigned To => christos
2018-10-01 18:48 christos Status new => assigned
2018-10-01 18:48 christos Status assigned => resolved
2018-10-01 18:48 christos Resolution open => fixed
2018-10-01 18:48 christos Fixed in Version => 5.35