Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2039407iob; Thu, 19 May 2022 23:46:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycoeSrmICuSHFXav+LJUxa5XERiiwSVmQQeKqK2PhdaaOGRuPepv2HZIAUIqaHbdF68pO6 X-Received: by 2002:a17:907:9688:b0:6fe:a0e9:ca6f with SMTP id hd8-20020a170907968800b006fea0e9ca6fmr4321669ejc.553.1653029163546; Thu, 19 May 2022 23:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653029163; cv=none; d=google.com; s=arc-20160816; b=MuiqnRTdQ+4Wgn0dH1bG3oJ7lx5XYzKbHBHytcUlx21J0rAUen2th06EMwFfjEkmLs wC2bzxbaDM12i+BMq+HmwUfxaOdCcnGNCfyG4PsFTDlJi212McpAn60BdqzlKuapnun2 zqwkAXh3gNEmWZu/DQzLmAFFecjKPKyc6bbjtbQmlgN74157MZNXqaRpP7mQyjtvjv+g OioSv18SfwFqAV9+Yepvr56tcY9I3A/k9RSUUzm0i0hbxS6+lwzuf9lxCWuUkgkCG0EL b/HDLpQJfLg/meCvRXz05IkLXOxqVFk0q/LrsY6/wJZrFQFJk9QSJAkoxtDcsEqGW5X7 aUyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=H846IO+fjJ5R46JqSkbj1tpySM3tu5H6t+OYD86b50Q=; b=0Qtd8wIOK9QQksjFovZ4TLotY4Za5VOT2E82tIVDJpWZcXmwf5yiQL0aHmgokVyQU2 p0JNZ8rTUazkpcRdhQFv/PwJ/FPwGliGg6IIIK/NRCec6rVJDj3/5ArlmznpyGIkD7A3 u5UGn7kutTPPK1rNxepIsrHCQ4RyxnTDyQTbZyWVUaQU+n6Iocq51jXbYGIXK4fmQLas 0n042plOQ95xE/FxzPyRifrwrGPFk3ZafTr03KP2Acmo78VsVXLy/XFQu6hUrjag3/Fi EEPpiA6fhj+/pkntzaUp7gRfAaz16UhpJVbTc86K925VQM9ppwH69c0/2KYcGBwp9rS5 5SDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HMJFGHxi; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a1709064fc800b006e81dd29c00si8257367ejw.569.2022.05.19.23.45.23; Thu, 19 May 2022 23:46:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HMJFGHxi; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234114AbiETERG (ORCPT + 99 others); Fri, 20 May 2022 00:17:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234070AbiETERG (ORCPT ); Fri, 20 May 2022 00:17:06 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 578C86B671 for ; Thu, 19 May 2022 21:17:05 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id h186so6749737pgc.3 for ; Thu, 19 May 2022 21:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=H846IO+fjJ5R46JqSkbj1tpySM3tu5H6t+OYD86b50Q=; b=HMJFGHxi7/CSmtHb+ntD0dJK5IZCryBRflgf2uqBVWox65ZsqOYsyHBAluHx6pVRtK ZqSyVNXtZEGHakkR0LxRTgkXdSIheWGW2AHmxrwecd8WVFuc8BpgFtPUUDvHitz/KCg1 dd20QFLBvqsmcY+Y9qTiJonX4wDBPxHzpOAsha43s5lzeWG0oNoCt1vVgrAVwOOUWITv 4P6Zf5a0oFawG45baTSgG8pcBHKuZJ8iB3Yp4wqkzXn+o/M3gDBCf2TfBWLka6ETlG06 eikHxNXsMVdRDbbn7SO/8BfqFPE9gwvb5rYbAmtH/vtZhi3t1vkFf4vCWTyhFT64fmqZ rWHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H846IO+fjJ5R46JqSkbj1tpySM3tu5H6t+OYD86b50Q=; b=Owc+bTCgdnDW1cL4T4quskqzEM0erPYhWJskWhfUOnt7+0g3THWOG7iwI2iHlcKUwO tljDz+gzDu8jE//LHkywLXV3Gp3ED3yIXd+lwVSCn/AWl/rZwFHVc9+piw/cylb4f5Zt P4at4cTb6X04HCpfcsThOvorWZiA/aVgTN5J6mSceGVa9orecq1SyXVmmXTtHCbXPkHM aVbxXhVw1ZM2MtRtYMV4b65qzpb4jQ5hGrBLyAVDHAo5yb2vRp/9N9+7rRAQdwWsjwmq SLKLyab1eytFAcf87ZcDO+EW4G/MhMRqtp/iE8tIsdPgSu9tzryU7Iwq2d1r2Njqoahx BwTw== X-Gm-Message-State: AOAM530bCgz8j7ThmrbMBNUe1WJK8KP4L4/3sSjEgOzgsVN9tW6Tfeor 8mdnvSWAKkqLBApbv8wCVZnzedOxeCc= X-Received: by 2002:a65:6e88:0:b0:382:3851:50c8 with SMTP id bm8-20020a656e88000000b00382385150c8mr6948098pgb.270.1653020224528; Thu, 19 May 2022 21:17:04 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id u13-20020a17090a450d00b001df955c28f6sm381405pjg.37.2022.05.19.21.17.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 21:17:03 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 3/7] monitor: Move print_hex_field to display.h Date: Thu, 19 May 2022 21:16:57 -0700 Message-Id: <20220520041701.2572197-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220520041701.2572197-1-luiz.dentz@gmail.com> References: <20220520041701.2572197-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This moves print_hex_field to display.h and removes the duplicated code from packet.c and l2cap.c. --- monitor/display.h | 14 ++++++++++++++ monitor/l2cap.c | 14 -------------- monitor/packet.c | 14 -------------- 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/monitor/display.h b/monitor/display.h index be5739833..5a82f8e6f 100644 --- a/monitor/display.h +++ b/monitor/display.h @@ -76,6 +76,20 @@ static inline uint64_t print_bitfield(int indent, uint64_t val, return mask; } +static inline void print_hex_field(const char *label, const uint8_t *data, + uint8_t len) +{ + char str[len * 2 + 1]; + uint8_t i; + + str[0] = '\0'; + + for (i = 0; i < len; i++) + sprintf(str + (i * 2), "%2.2x", data[i]); + + print_field("%s: %s", label, str); +} + void set_default_pager_num_columns(int num_columns); int num_columns(void); diff --git a/monitor/l2cap.c b/monitor/l2cap.c index 01825ce0a..192b6c920 100644 --- a/monitor/l2cap.c +++ b/monitor/l2cap.c @@ -2123,20 +2123,6 @@ static void amp_packet(uint16_t index, bool in, uint16_t handle, opcode_data->func(&frame); } -static void print_hex_field(const char *label, const uint8_t *data, - uint8_t len) -{ - char str[len * 2 + 1]; - uint8_t i; - - str[0] = '\0'; - - for (i = 0; i < len; i++) - sprintf(str + (i * 2), "%2.2x", data[i]); - - print_field("%s: %s", label, str); -} - static void print_uuid(const char *label, const void *data, uint16_t size) { const char *str; diff --git a/monitor/packet.c b/monitor/packet.c index d80735a06..2e02b3923 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -1755,20 +1755,6 @@ static void print_key_size(uint8_t key_size) print_field("Key size: %d", key_size); } -static void print_hex_field(const char *label, const uint8_t *data, - uint8_t len) -{ - char str[len * 2 + 1]; - uint8_t i; - - str[0] = '\0'; - - for (i = 0; i < len; i++) - sprintf(str + (i * 2), "%2.2x", data[i]); - - print_field("%s: %s", label, str); -} - static void print_key(const char *label, const uint8_t *link_key) { print_hex_field(label, link_key, 16); -- 2.35.1