From nobody Wed Nov 19 03:04:30 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1614341265; cv=none; d=zohomail.com; s=zohoarc; b=fxl9D6XiGJRg9MxJ/cJ+Uqw+PyOY6OFinJklvNCgcrmHtQoJ3lTu8sXCNnx+JUCPGenu4JR5CUBGLWllSSgqxQBBL9wSXelri5kyTxhy/rzosoV/385Jncbfn+Jk/SN11nHmjupomi2Hw+EhOk1LtRdRL9ahoiUgTGfR4OPvARM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614341265; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=5sSUGjJl0N9rSE3mNsymbDryUSITyUiRDPA98/1ZvGo=; b=n+GT0wGGRFAti7p6D0dt6Ny/xTKE2lAL3cBw7yP6YmJ15QBjqX+YE3NeUraQvw4cRDnQN+TU6L14Lc/o1z3fYk3g249+BTAhtoiM3WCbynCHKJScXZuNvO2zaK9ZUrlbKKsDbUeoimSryrdDWeAPZqEFF4+4jT3qVvkNiSKqQvA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614341265776269.78033294637396; Fri, 26 Feb 2021 04:07:45 -0800 (PST) Received: from localhost ([::1]:39856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lFbuI-0001fb-So for importer@patchew.org; Fri, 26 Feb 2021 07:07:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lFbt3-00011d-ID for qemu-devel@nongnu.org; Fri, 26 Feb 2021 07:06:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47811) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lFbt0-0008LH-Ia for qemu-devel@nongnu.org; Fri, 26 Feb 2021 07:06:24 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-405-vrbIAKLDNrGyBGBYoGwk0g-1; Fri, 26 Feb 2021 07:06:17 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ADC3C1868404; Fri, 26 Feb 2021 12:06:16 +0000 (UTC) Received: from localhost (unknown [10.36.110.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 667B8E2E2; Fri, 26 Feb 2021 12:06:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614341181; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5sSUGjJl0N9rSE3mNsymbDryUSITyUiRDPA98/1ZvGo=; b=SSxE+zTKuKmm+zFT0BC5CJL6Jvvu+X/xVXIdEZPWToqS3J+NGdHpYcNrvyFkBKfac/myQr NR6SPabUMCFwvcuhv2f2LSuuV1ljVKyjNPSKtG65xGT8d/CqwpuTXxtrEV8RxRN5Uxt3FN TpdMpHZL0ir/8t5ejomJ/rNdvr96vow= X-MC-Unique: vrbIAKLDNrGyBGBYoGwk0g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH] net: remove qemu_ether_ntoa() Date: Fri, 26 Feb 2021 16:06:07 +0400 Message-Id: <20210226120607.675753-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , jasowang@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau The function is not thread-safe and sets a bad example. It's used in a single place for tracing, so open-code the format string like other trace events with MAC addresses. Cc: qemu-trivial@nongnu.org Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu-common.h | 1 - net/announce.c | 8 +++++++- util/cutils.c | 13 ------------- net/trace-events | 2 +- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/include/qemu-common.h b/include/qemu-common.h index 654621444e..209133bfca 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -132,7 +132,6 @@ void qemu_hexdump(FILE *fp, const char *prefix, */ int parse_debug_env(const char *name, int max, int initial); =20 -const char *qemu_ether_ntoa(const MACAddr *mac); void page_size_init(void); =20 /* returns non-zero if dump is in progress, otherwise zero is diff --git a/net/announce.c b/net/announce.c index 26f057f5ee..fc0c6baace 100644 --- a/net/announce.c +++ b/net/announce.c @@ -146,7 +146,13 @@ static void qemu_announce_self_iter(NICState *nic, voi= d *opaque) =20 trace_qemu_announce_self_iter(timer->params.has_id ? timer->params.id = : "_", nic->ncs->name, - qemu_ether_ntoa(&nic->conf->macaddr), sk= ip); + nic->conf->macaddr.a[0], + nic->conf->macaddr.a[1], + nic->conf->macaddr.a[2], + nic->conf->macaddr.a[3], + nic->conf->macaddr.a[4], + nic->conf->macaddr.a[5], + skip); =20 if (!skip) { len =3D announce_self_create(buf, nic->conf->macaddr.a); diff --git a/util/cutils.c b/util/cutils.c index 70c7d6efbd..b5460a72b4 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -847,19 +847,6 @@ int parse_debug_env(const char *name, int max, int ini= tial) return debug; } =20 -/* - * Helper to print ethernet mac address - */ -const char *qemu_ether_ntoa(const MACAddr *mac) -{ - static char ret[18]; - - snprintf(ret, sizeof(ret), "%02x:%02x:%02x:%02x:%02x:%02x", - mac->a[0], mac->a[1], mac->a[2], mac->a[3], mac->a[4], mac->a= [5]); - - return ret; -} - /* * Return human readable string for size @val. * @val can be anything that uint64_t allows (no more than "16 EiB"). diff --git a/net/trace-events b/net/trace-events index bfaff7891d..07d6203602 100644 --- a/net/trace-events +++ b/net/trace-events @@ -1,7 +1,7 @@ # See docs/devel/tracing.txt for syntax documentation. =20 # announce.c -qemu_announce_self_iter(const char *id, const char *name, const char *mac,= int skip) "%s:%s:%s skip: %d" +qemu_announce_self_iter(const char *id, const char *name, char mac0, char = mac1, char mac2, char mac3, char mac4, char mac5, int skip) "%s:%s:%02x:%02= x:%02x:%02x:%02x:%02x skip: %d" qemu_announce_timer_del(bool free_named, bool free_timer, char *id) "free = named: %d free timer: %d id: %s" =20 # vhost-user.c --=20 2.29.0