linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: zuoqilin1@163.com
To: robh+dt@kernel.org, frowand.list@gmail.com
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	zuoqilin <zuoqilin@yulong.com>
Subject: [PATCH] scripts/dtc: Assign value when defining variables
Date: Tue, 18 May 2021 14:07:25 +0800	[thread overview]
Message-ID: <20210518060725.1984-1-zuoqilin1@163.com> (raw)

From: zuoqilin <zuoqilin@yulong.com>

When defining variables and assigning values can be done at the same time.

Signed-off-by: zuoqilin <zuoqilin@yulong.com>
---
 scripts/dtc/util.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/scripts/dtc/util.c b/scripts/dtc/util.c
index 40274fb..d1f7608 100644
--- a/scripts/dtc/util.c
+++ b/scripts/dtc/util.c
@@ -292,7 +292,7 @@ int utilfdt_write_err(const char *filename, const void *blob)
 {
 	int fd = 1;	/* assume stdout */
 	int totalsize;
-	int offset;
+	int offset = 0;
 	int ret = 0;
 	const char *ptr = blob;
 
@@ -303,7 +303,6 @@ int utilfdt_write_err(const char *filename, const void *blob)
 	}
 
 	totalsize = fdt_totalsize(blob);
-	offset = 0;
 
 	while (offset < totalsize) {
 		ret = write(fd, ptr + offset, totalsize - offset);
@@ -421,7 +420,7 @@ void NORETURN util_usage(const char *errmsg, const char *synopsis,
 	const char a_arg[] = "<arg>";
 	size_t a_arg_len = strlen(a_arg) + 1;
 	size_t i;
-	int optlen;
+	int optlen = 0;
 
 	fprintf(fp,
 		"Usage: %s\n"
@@ -429,7 +428,6 @@ void NORETURN util_usage(const char *errmsg, const char *synopsis,
 		"Options: -[%s]\n", synopsis, short_opts);
 
 	/* prescan the --long opt length to auto-align */
-	optlen = 0;
 	for (i = 0; long_opts[i].name; ++i) {
 		/* +1 is for space between --opt and help text */
 		int l = strlen(long_opts[i].name) + 1;
-- 
1.9.1



             reply	other threads:[~2021-05-18  6:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18  6:07 zuoqilin1 [this message]
2021-05-18 17:01 ` [PATCH] scripts/dtc: Assign value when defining variables Rob Herring

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=20210518060725.1984-1-zuoqilin1@163.com \
    --to=zuoqilin1@163.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=zuoqilin@yulong.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).