Source-Changes-HG archive

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

[src/trunk]: src/tests/fs/tmpfs - Add inttypes.h #include for PR* macros.



details:   https://anonhg.NetBSD.org/src/rev/7be960dc0b64
branches:  trunk
changeset: 829099:7be960dc0b64
user:      maya <maya%NetBSD.org@localhost>
date:      Wed Jan 17 00:22:29 2018 +0000

description:
- Add inttypes.h #include for PR* macros.
- close fd when done to prevent leak.
- use correct socket length when calling bind(2).

>From Ngie Cooper in PR bin/51870

diffstat:

 tests/fs/tmpfs/h_tools.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r 5e037e0f9f69 -r 7be960dc0b64 tests/fs/tmpfs/h_tools.c
--- a/tests/fs/tmpfs/h_tools.c  Wed Jan 17 00:16:43 2018 +0000
+++ b/tests/fs/tmpfs/h_tools.c  Wed Jan 17 00:22:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: h_tools.c,v 1.4 2011/06/11 18:03:17 christos Exp $     */
+/*     $NetBSD: h_tools.c,v 1.5 2018/01/17 00:22:29 maya Exp $ */
 
 /*
  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -45,6 +45,7 @@
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -230,12 +231,13 @@
                return EXIT_FAILURE;
        }
 
+       memset(&addr, 0, sizeof(addr));
        (void)strlcpy(addr.sun_path, argv[1], sizeof(addr.sun_path));
        addr.sun_family = PF_UNIX;
-
-       error = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
+       error = bind(fd, (struct sockaddr *)&addr, SUN_LEN(&addr));
        if (error == -1) {
                warn("connect");
+               (void)close(fd);
                return EXIT_FAILURE;
        }
 



Home | Main Index | Thread Index | Old Index