From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 31466A034E; Wed, 27 May 2020 16:53:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B46C31D5A7; Wed, 27 May 2020 16:53:54 +0200 (CEST) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id ECF8F1D421 for ; Wed, 27 May 2020 16:53:53 +0200 (CEST) Received: by mail-pl1-f195.google.com with SMTP id m7so10221862plt.5 for ; Wed, 27 May 2020 07:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dnAVtdhxL1wjIvJszrZFoVhRz/SWzHVFIB2wKEuAVAU=; b=1Vqxj6IdFHvsyp04XpxuWNJwDAZ2IP2FdcD+QDK5TuEaDOw+jzZ7n2PcMNk1rlCXp2 6zreurx+qYTXZFIXWhFZxNDJv/V2Pk653TMmch5Z9jcetRfezlWVOGKKVN9i9o7fBuhg BQVZ32ULdmT4l5jxBhw4EfvhPynolQ+gYodim+AYuAwBtlxGn4IuVoc4oxwUTOFKjUoX wd69VRhlFl4/ExxJilwaLtllAZ+aqCKY1nVuKF352uepmyaJiaGRyK8Mdl4j0Ff6jOnk xvWrB+UZ2labI3KeRBvH4svLkMy9C4S9skWvKf3ah/nKRDZpFmra+hl9m8CzH+hx1fbS QFig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dnAVtdhxL1wjIvJszrZFoVhRz/SWzHVFIB2wKEuAVAU=; b=X8Jq9XozlAF3VEXcFXosG01iaJV3Ve/gwNw2Q2d4IiaIACFt3HrajYIxqid/GCFidG Qr6J6rKiXZOaQa4Ex8HyaEw58KQby7JpwmmpvuYwzemUb0XfV5qtYjGF0h66wBe52NDE YaK/TpPWAzl6oGRffUfLBJIHsmsoOkTYUD/5CCjhJwofiIkqv7HpwRIYaUX+iS9hwP7d cFKuZGmbbtg6/flVqm+3Gqxg+Q6SLwrfLl5YRs4UhisJ1drgwHSFUy6yKY6fqIn7WWPC tHJ6HnUfLBjPEKzA6P4hZ/a7BAC3/3RzhVOXwoq4HTPoFXhEZnjlIVGvphrGGToX2vMM JY4w== X-Gm-Message-State: AOAM533r/7oDo/huRljD0sJ3KW1NSqpOaREn4TA7cILB720lXOLZk3UA zSeBfgwkYu4ledo+7yZ42mTnsg== X-Google-Smtp-Source: ABdhPJxyCTkJv1XmSShcaSjKKjqhVb6m6uIEsFxOxml/fxvzVsnMoE98DFQuGDxIsPysjpy6z5gI3Q== X-Received: by 2002:a17:90b:1081:: with SMTP id gj1mr5464948pjb.6.1590591233010; Wed, 27 May 2020 07:53:53 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j26sm2313870pfr.215.2020.05.27.07.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 07:53:52 -0700 (PDT) Date: Wed, 27 May 2020 07:53:44 -0700 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: , , , , , , , , , , , Message-ID: <20200527075344.4b9e346b@hermes.lan> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35C6100A@smartserver.smartshare.dk> References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200526191033.16459-1-i.dyukov@samsung.com> <20200526191033.16459-3-i.dyukov@samsung.com> <98CBD80474FA8B44BF855DF32C47DC35C6100A@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH v2 2/7] ethdev: add a link status textrepresentation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, 27 May 2020 09:45:49 +0200 Morten Br=C3=B8rup wrote: > void rte_eth_link_prepare_text(char *str, const struct rte_eth_link *cons= t link) > { > if (link.link_status =3D=3D ETH_LINK_DOWN) { > str +=3D sprintf(str, "Link down"); > } else { > str +=3D sprintf(str, "Link up at "); > if (link.link_speed =3D=3D ETH_SPEED_NUM_UNKNOWN) { > str +=3D sprintf("Unknown speed"); > } else { > if (link.link_speed < ETH_SPEED_NUM_1G) > str +=3D sprintf(str, "%u Mbit/s", link.link_speed); > else if (link.link_speed =3D=3D ETH_SPEED_NUM_2_5G) > str +=3D sprintf(str, "2.5 Gbit/s"); > else > str +=3D sprintf(str, "%u Gbit/s", link.link_speed / 1000= ); > str +=3D sprintf(str, " %cDX", link.link_duplex ? 'F' : 'H'); > str +=3D sprintf(str, " %s", link.link_autoneg ? "Autoneg" : = "Fixed"); > } > } > } Having a semi-standard link status text is good. This version of the code needs work before it is ready. Using sprintf() rather than snprintf() is going to upset the security folks. The API must take string and length, or use asprintf(); You don't want to do last increment or Coverity will complain about useless= assignment.