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:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ GNUnet-developers mailing list [email protected] https://lists.gnu.org/mailman/listinfo/gnunet-developers
