gnunet-developers
[Top][All Lists]
Advanced

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

Re: [GNUnet-developers] using $TMPDIR instead of /tmp


From: Christian Grothoff
Subject: Re: [GNUnet-developers] using $TMPDIR instead of /tmp
Date: Mon, 7 May 2018 10:39:47 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

On 05/07/2018 10:03 AM, Nils Gillmann wrote:
> I've just started looking into our C code, and C in general, more.
> In src/transport/gnunet-helper-transport-wlan-dummy.c
> we define 2 fifo files (FIFO_FILE1, FIFO_FILE2). Those are currently
> #define FIFO_FILE1 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_in"
> #define FIFO_FILE1 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_out"
> 
> Would
> 
> #define FIFO_FILE1 GNUNET_DISK_mktemp("test-transport/api-wlan-p1/") 
> "WLAN_FIFO_in"
> 
> work? 

Eh, no. This shouldn't even compile. C is not a script language, and
foo() "bar" is not syntactically valid even if foo() returns a char*.

Also, even if it did, you'd create a memory leak.  To do this right, you
have to replace all uses of the macro with something like:

char *tdir;
char *dir;

tdir = GNUNET_DISK_mktemp ("foo");
GNUNET_asprintf (&dir, "%sWLAN_FIFO_in", tdir);
GNUNET_free (tdir);
// use (dir);  -> was: use (FIFO_FILE1);
GNUNET_free (dir);

> the tests are still failing with this, but it seems like the right directories
> and files are created.
> 
> test-suite.log (one file still had "/tmp" but in the right location, via 
> GNUNET_DISK_mktemp:

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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