From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id 4582D5586 for ; Thu, 21 Jul 2016 16:35:46 +0200 (CEST) Received: by mail-wm0-f41.google.com with SMTP id q128so24122324wma.1 for ; Thu, 21 Jul 2016 07:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:user-agent:in-reply-to :references:mime-version:content-transfer-encoding; bh=y54+gapWogmpKZv/VJqHUSJP49j6t0yHL52aSs9XzpU=; b=FlLDaUL79XuN2TEx/FboDZundco+1Ssi0D+hMzSlmILVicBnkdsOmfY3/up/gHaYH5 Hnj5V/eO/LrfKEUiOg0f26PFHB4fi1uaNLrApLmt7aUSrBzxWgJHP3Drk5APFNVHdbXl husxKcE6Z1qCllOavlI7Y/Op0UGkLmHr1cU9am8jlsPi8ZoQMoM+A04DFPdqsdFSDKnk wD0xe9bOqysNbeEPb8jdraXHdWi5NKMWS3H/1wHI9u2tz9OZpPCnZeBkUWvx/H7ZeEUv N12TU6ESF/KxyK2WUPuvOPI2GdVHlDbs6ivYoXYOqNBIg4pIX78/8ikFsbGpQRZI8rWH 1SPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :in-reply-to:references:mime-version:content-transfer-encoding; bh=y54+gapWogmpKZv/VJqHUSJP49j6t0yHL52aSs9XzpU=; b=ZdtYnCrH+hw5EWgLc7UYAiAmxfigVIFYoDAU3gCPOX4JjGtV9md/fR3GRqRVX21BaM HhQ9iETL3YPAguwv+MPxqatfJCaZEiiGbqjLHAr1nH38rV/04e5KdvuAuMtXv6cOySgY 3ni5hNrpNxkIy3wZfPA6DXFnQbNK76b07LG3A1QdrYEEklptu+T90f31VLL9nPE23B8e F8dZuEfcxWgFIFUG01p37CxRoBT+P1sDcRwy1bjbbgOCN5G+hjsz4iM+x4GDMhEvddEE fiFBuuZgZ7sf0u5aiz+/HZFJL0jaFzhS+8sRGUnaUjDmC/P6GZcAV8Tai0tMaczcQzLV WaLA== X-Gm-Message-State: ALyK8tLRxyN5p3S/mvMMZvW04aS5msEl3N5E/5ayKcis4lrl62yqANT2ckfOkFjSzFpQ6ja0 X-Received: by 10.28.222.8 with SMTP id v8mr18980333wmg.55.1469111745943; Thu, 21 Jul 2016 07:35:45 -0700 (PDT) Received: from xps13.localnet (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id e65sm4575148wmg.3.2016.07.21.07.35.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jul 2016 07:35:45 -0700 (PDT) From: Thomas Monjalon To: Michal Jastrzebski Cc: dev@dpdk.org, bruce.richardson@intel.com, michalx.kobylinski@intel.com, sergio.gonzalez.monroy@intel.com, david.marchand@6wind.com Date: Thu, 21 Jul 2016 16:35:44 +0200 Message-ID: <1862165.0hl8WtbyGd@xps13> User-Agent: KMail/4.14.10 (Linux/4.5.4-1-ARCH; KDE/4.14.11; x86_64; ; ) In-Reply-To: <1469024689-1076-1-git-send-email-michalx.k.jastrzebski@intel.com> References: <1469024689-1076-1-git-send-email-michalx.k.jastrzebski@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH] eal: fix check number of bytes from read function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2016 14:35:46 -0000 Hi, 2016-07-20 16:24, Michal Jastrzebski: > - if (read(fd, &page, sizeof(uint64_t)) < 0) { > + > + retval = read(fd, &page, sizeof(uint64_t)); > + if (retval < 0) { > RTE_LOG(ERR, EAL, "%s(): cannot read /proc/self/pagemap: %s\n", > __func__, strerror(errno)); > close(fd); > return RTE_BAD_PHYS_ADDR; > + } else if (retval >= 0 && retval < (int)sizeof(uint64_t)) { I have 4 comments about the above line: - the check retval >= 0 is not needed because implied by else - why not checking retval != sizeof(uint64_t) as it is the exact expected value? - (int)sizeof(uint64_t) can be replaced by 8 but it's shorter ;) - only 1 space is required between } and else > + RTE_LOG(ERR, EAL, "%s(): read %d bytes from /proc/self/pagemap " > + "but expected %d: %s\n", > + __func__, retval, (int)sizeof(uint64_t), strerror(errno)); Are you sure errno is meaningful here? > + close(fd); > + return RTE_BAD_PHYS_ADDR; > }