From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: rkrcmar@redhat.com, pbonzini@redhat.com, lvivier@redhat.com,
thuth@redhat.com
Subject: [PATCH kvm-unit-tests 01/15] devicetree: improve dt_get_bootargs interface
Date: Fri, 13 Jan 2017 19:15:19 +0100 [thread overview]
Message-ID: <20170113181533.15145-2-drjones@redhat.com> (raw)
In-Reply-To: <20170113181533.15145-1-drjones@redhat.com>
Don't lie to callers when bootargs wasn't found, they can check
for themselves. Also document that when a failure occurs @bootargs
will be NULL.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
lib/devicetree.h | 5 +++--
lib/arm/setup.c | 2 +-
lib/devicetree.c | 5 ++---
lib/powerpc/setup.c | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/devicetree.h b/lib/devicetree.h
index 0083587633d4..9a4d910b6450 100644
--- a/lib/devicetree.h
+++ b/lib/devicetree.h
@@ -202,10 +202,11 @@ extern int dt_get_reg(int fdtnode, int regidx, struct dt_reg *reg);
**********************************************************************/
/*
- * dt_get_bootargs gets a pointer to /chosen/bootargs
+ * dt_get_bootargs gets the string pointer from /chosen/bootargs
* returns
* - zero on success
- * - a negative FDT_ERR_* value on failure
+ * - a negative FDT_ERR_* value on failure, and @bootargs
+ * will be set to NULL
*/
extern int dt_get_bootargs(const char **bootargs);
diff --git a/lib/arm/setup.c b/lib/arm/setup.c
index 68eae91286d6..dc94d312b262 100644
--- a/lib/arm/setup.c
+++ b/lib/arm/setup.c
@@ -138,6 +138,6 @@ void setup(const void *fdt)
io_init();
ret = dt_get_bootargs(&bootargs);
- assert(ret == 0);
+ assert(ret == 0 || ret == -FDT_ERR_NOTFOUND);
setup_args_progname(bootargs);
}
diff --git a/lib/devicetree.c b/lib/devicetree.c
index 671c64a2ca51..509649b917cf 100644
--- a/lib/devicetree.c
+++ b/lib/devicetree.c
@@ -256,11 +256,10 @@ int dt_get_bootargs(const char **bootargs)
return node;
prop = fdt_get_property(fdt, node, "bootargs", &len);
- if (prop)
- *bootargs = prop->data;
- else if (len < 0 && len != -FDT_ERR_NOTFOUND)
+ if (!prop)
return len;
+ *bootargs = prop->data;
return 0;
}
diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c
index d56de36410c7..00969da8f12c 100644
--- a/lib/powerpc/setup.c
+++ b/lib/powerpc/setup.c
@@ -176,6 +176,6 @@ void setup(const void *fdt)
io_init();
ret = dt_get_bootargs(&bootargs);
- assert(ret == 0);
+ assert(ret == 0 || ret == -FDT_ERR_NOTFOUND);
setup_args_progname(bootargs);
}
--
2.9.3
next prev parent reply other threads:[~2017-01-13 18:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-13 18:15 [PATCH kvm-unit-tests 00/15] Introduce an errata framework Andrew Jones
2017-01-13 18:15 ` Andrew Jones [this message]
2017-01-13 18:15 ` [PATCH kvm-unit-tests 02/15] devicetree: introduce dt_get_initrd Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 03/15] arm/arm64: better document setup Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 04/15] powerpc: " Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 05/15] arm/arm64: import initrd Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 06/15] powerpc: " Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 07/15] x86_64: mbi-cmdline is a 4 byte addr Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 08/15] x86: import initrd Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 09/15] lib/argv: fix coding style Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 10/15] lib/argv: introduce setup_env and getenv Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 11/15] arm/arm64: enable environ Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 12/15] powerpc: " Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 13/15] x86: " Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 14/15] README: reserve some environment variables Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 15/15] Introduce lib/errata.h Andrew Jones
2017-03-03 14:40 ` Radim Krčmář
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170113181533.15145-2-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.