All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: jani.nikula@intel.com
Subject: [PATCH i-g-t 3/8] tools/intel_vbt_decode: use %.*s instead of duplicating a string
Date: Thu, 19 Oct 2017 18:22:54 +0300	[thread overview]
Message-ID: <20171019152259.31615-4-jani.nikula@intel.com> (raw)
In-Reply-To: <20171019152259.31615-1-jani.nikula@intel.com>

child->device_id may not be terminated, but we can use %.*s format
specifier to define the max length to print. No need to make a copy.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_vbt_decode.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tools/intel_vbt_decode.c b/tools/intel_vbt_decode.c
index 4865f0bab25f..0f7e2dafc762 100644
--- a/tools/intel_vbt_decode.c
+++ b/tools/intel_vbt_decode.c
@@ -388,19 +388,15 @@ static void dump_child_device(struct context *context,
 			      const struct child_device_config *child)
 {
 	const struct child_device_config *efp = child;
-	char child_id[11];
 
 	if (!child->device_type)
 		return;
 
 	if (context->bdb->version < 152) {
-		strncpy(child_id, (const char *)child->device_id, 10);
-		child_id[10] = 0;
-
 		printf("\tChild device info:\n");
 		printf("\t\tDevice type: %04x (%s)\n", child->device_type,
 		       child_device_type(child->device_type));
-		printf("\t\tSignature: %s\n", child_id);
+		printf("\t\tSignature: %.*s\n", (int)sizeof(child->device_id), child->device_id);
 		printf("\t\tAIM offset: %d\n", child->addin_offset);
 		printf("\t\tDVO port: 0x%02x\n", child->dvo_port);
 	} else { /* 152+ have EFP blocks here */
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-10-19 15:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 15:22 [PATCH i-g-t 0/8] tools/intel_vbt_decode: refactoring and cleanups Jani Nikula
2017-10-19 15:22 ` [PATCH i-g-t 1/8] tools/intel_vbt_decode: make a copy of child devices before dumping Jani Nikula
2017-10-19 15:22 ` [PATCH i-g-t 2/8] tools/intel_vbt_decode: update dvo port name dumping Jani Nikula
2017-10-19 15:22 ` Jani Nikula [this message]
2017-10-19 15:22 ` [PATCH i-g-t 4/8] tools/intel_vbt_decode: abstract DSI bridge type dump Jani Nikula
2017-10-19 15:22 ` [PATCH i-g-t 5/8] tools/intel_vbt_decode: unify child device printing across versions Jani Nikula
2017-10-19 17:24   ` Ville Syrjälä
2017-10-20 10:56     ` Jani Nikula
2017-10-20 11:33       ` Ville Syrjälä
2017-10-20 13:17         ` Jani Nikula
2017-10-20 13:49           ` Ville Syrjälä
2017-10-19 15:22 ` [PATCH i-g-t 6/8] tools/intel_vbt_decode: unify legacy child device block dumping Jani Nikula
2017-10-19 15:22 ` [PATCH i-g-t 7/8] tools/intel_vbt_decode: dump more child device data for version < 152 Jani Nikula
2017-10-19 15:22 ` [PATCH i-g-t 8/8] tools/intel_vbt_decode: abstract child devices printing more Jani Nikula
2017-10-19 16:52 ` ✗ Fi.CI.BAT: failure for tools/intel_vbt_decode: refactoring and cleanups Patchwork

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=20171019152259.31615-4-jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /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.