bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] [PATCH] Fixing C89 warnings


From: Tim Rühsen
Subject: Re: [Bug-wget] [PATCH] Fixing C89 warnings
Date: Wed, 19 Nov 2014 19:33:24 +0100
User-agent: KMail/4.14.2 (Linux/3.16.0-4-amd64; KDE/4.14.2; x86_64; ; )

Am Mittwoch, 19. November 2014, 22:07:28 schrieb Darshit Shah:
> On 11/18, Tim Rühsen wrote:
> >This patch fixes most C89 warnings for me (-std=c89 -pedantic) since these
> >may prevent from compiling with MSVC.
> >
> >There are still some warnings "ISO C forbids conversion of function pointer
> >to object pointer type [-Wpedantic]" left over. I'll care for these the
> >next days. There are architectures where function pointers have a
> >different size from void *. That's why this warning has a meaning.
> >
> >Tim
> >
> >From 11baace21e1fa04a92baa395f38ebad8001e9762 Mon Sep 17 00:00:00 2001
> >From: Tim Ruehsen <address@hidden>
> >Date: Tue, 18 Nov 2014 22:00:48 +0100
> >Subject: [PATCH] Trivial fixes for C89 compliancy.
> 
> <snip>
> 
> >diff --git a/src/gnutls.c b/src/gnutls.c
> >index 87d1d0b..42201e5 100644
> >--- a/src/gnutls.c
> >+++ b/src/gnutls.c
> >@@ -54,6 +54,10 @@ as that of the covered work.  */
> >
> > # include "w32sock.h"
> > #endif
> >
> >+#ifdef HAVE_ALLOCA_H
> >+# include <alloca.h>
> >+#endif
> >+
> >
> > #include "host.h"
> > 
> > static int
> >
> >@@ -122,9 +126,10 @@ ssl_init (void)
> >
> >           while ((dent = readdir (dir)) != NULL)
> >           
> >             {
> >             
> >               struct stat st;
> >
> >-              char ca_file[dirlen + strlen(dent->d_name) + 2];
> >+              size_t ca_file_length = dirlen + strlen(dent->d_name) + 2;
> >+              char *ca_file = alloca(ca_file_length);
> 
> What happens when HAVE_ALLOCA_H is not defined? The above code will attempt
> to call a function that does not exist and Wget will crash.
> 
> I think, we can simply malloc / free() these. Sure alloca is more
> convenient, but we need a valid fallback for when it is not available.

There are systems without alloca.h header file. Thus the check.
(I just had an error report for libpsl with this issue.)

I do not know systems without alloca() function.
Wget sources already use alloca on several places.

Tim

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]