Tue Feb 26 15:55:33 2019 UTC ()
Compute storage size for a string correctly.


(joerg)
diff -r1.39 -r1.40 src/sys/arch/xen/xenbus/xenbus_probe.c

cvs diff -r1.39 -r1.40 src/sys/arch/xen/xenbus/xenbus_probe.c (expand / switch to unified diff)

--- src/sys/arch/xen/xenbus/xenbus_probe.c 2016/07/07 06:55:40 1.39
+++ src/sys/arch/xen/xenbus/xenbus_probe.c 2019/02/26 15:55:33 1.40
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: xenbus_probe.c,v 1.39 2016/07/07 06:55:40 msaitoh Exp $ */ 1/* $NetBSD: xenbus_probe.c,v 1.40 2019/02/26 15:55:33 joerg Exp $ */
2/****************************************************************************** 2/******************************************************************************
3 * Talks to Xen Store to figure out what devices we have. 3 * Talks to Xen Store to figure out what devices we have.
4 * 4 *
5 * Copyright (C) 2005 Rusty Russell, IBM Corporation 5 * Copyright (C) 2005 Rusty Russell, IBM Corporation
6 * Copyright (C) 2005 Mike Wray, Hewlett-Packard 6 * Copyright (C) 2005 Mike Wray, Hewlett-Packard
7 * Copyright (C) 2005 XenSource Ltd 7 * Copyright (C) 2005 XenSource Ltd
8 *  8 *
9 * This file may be distributed separately from the Linux kernel, or 9 * This file may be distributed separately from the Linux kernel, or
10 * incorporated into other software packages, subject to the following license: 10 * incorporated into other software packages, subject to the following license:
11 *  11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a copy 12 * Permission is hereby granted, free of charge, to any person obtaining a copy
13 * of this source file (the "Software"), to deal in the Software without 13 * of this source file (the "Software"), to deal in the Software without
14 * restriction, including without limitation the rights to use, copy, modify, 14 * restriction, including without limitation the rights to use, copy, modify,
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * The above copyright notice and this permission notice shall be included in 19 * The above copyright notice and this permission notice shall be included in
20 * all copies or substantial portions of the Software. 20 * all copies or substantial portions of the Software.
21 *  21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28 * IN THE SOFTWARE. 28 * IN THE SOFTWARE.
29 */ 29 */
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.39 2016/07/07 06:55:40 msaitoh Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.40 2019/02/26 15:55:33 joerg Exp $");
33 33
34#if 0 34#if 0
35#define DPRINTK(fmt, args...) \ 35#define DPRINTK(fmt, args...) \
36 printf("xenbus_probe (%s:%d) " fmt ".\n", __func__, __LINE__, ##args) 36 printf("xenbus_probe (%s:%d) " fmt ".\n", __func__, __LINE__, ##args)
37#else 37#else
38#define DPRINTK(fmt, args...) ((void)0) 38#define DPRINTK(fmt, args...) ((void)0)
39#endif 39#endif
40 40
41#include <sys/types.h> 41#include <sys/types.h>
42#include <sys/null.h> 42#include <sys/null.h>
43#include <sys/errno.h> 43#include <sys/errno.h>
44#include <sys/malloc.h> 44#include <sys/malloc.h>
45#include <sys/systm.h> 45#include <sys/systm.h>
@@ -613,31 +613,31 @@ xenbus_probe(void *unused) @@ -613,31 +613,31 @@ xenbus_probe(void *unused)
613{ 613{
614 struct xenbusdev_attach_args balloon_xa = { 614 struct xenbusdev_attach_args balloon_xa = {
615 .xa_id = 0, 615 .xa_id = 0,
616 .xa_type = "balloon" 616 .xa_type = "balloon"
617 }; 617 };
618 618
619 KASSERT((xenstored_ready > 0)); 619 KASSERT((xenstored_ready > 0));
620 620
621 /* Enumerate devices in xenstore. */ 621 /* Enumerate devices in xenstore. */
622 xenbus_probe_frontends(); 622 xenbus_probe_frontends();
623 xenbus_probe_backends(); 623 xenbus_probe_backends();
624 624
625 /* Watch for changes. */ 625 /* Watch for changes. */
626 fe_watch.node = malloc(strlen("device" + 1), M_DEVBUF, M_NOWAIT); 626 fe_watch.node = malloc(strlen("device") + 1, M_DEVBUF, M_NOWAIT);
627 strcpy(fe_watch.node, "device"); 627 strcpy(fe_watch.node, "device");
628 fe_watch.xbw_callback = frontend_changed; 628 fe_watch.xbw_callback = frontend_changed;
629 register_xenbus_watch(&fe_watch); 629 register_xenbus_watch(&fe_watch);
630 be_watch.node = malloc(strlen("backend" + 1), M_DEVBUF, M_NOWAIT); 630 be_watch.node = malloc(strlen("backend") + 1, M_DEVBUF, M_NOWAIT);
631 strcpy(be_watch.node, "backend"); 631 strcpy(be_watch.node, "backend");
632 be_watch.xbw_callback = backend_changed; 632 be_watch.xbw_callback = backend_changed;
633 register_xenbus_watch(&be_watch); 633 register_xenbus_watch(&be_watch);
634 634
635 /* attach balloon. */ 635 /* attach balloon. */
636 config_found_ia(xenbus_dev, "xenbus", &balloon_xa, xenbus_print); 636 config_found_ia(xenbus_dev, "xenbus", &balloon_xa, xenbus_print);
637 637
638 shutdown_xenbus_setup(); 638 shutdown_xenbus_setup();
639 639
640 /* Notify others that xenstore is up */ 640 /* Notify others that xenstore is up */
641 //notifier_call_chain(&xenstore_chain, 0, NULL); 641 //notifier_call_chain(&xenstore_chain, 0, NULL);
642} 642}
643 643