From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zoltan Kiss Subject: RING_HAS_UNCONSUMED_REQUESTS oddness Date: Thu, 6 Mar 2014 15:47:08 +0000 Message-ID: <5318987C.3030303@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WLaVt-0000MV-IZ for xen-devel@lists.xenproject.org; Thu, 06 Mar 2014 15:47:13 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "xen-devel@lists.xenproject.org" , Wei Liu , Ian Campbell List-Id: xen-devel@lists.xenproject.org Hi, I was wondering for a while why this macro looks like this: #define RING_HAS_UNCONSUMED_REQUESTS(_r) \ ({ \ unsigned int req = (_r)->sring->req_prod - (_r)->req_cons; \ unsigned int rsp = RING_SIZE(_r) - \ ((_r)->req_cons - (_r)->rsp_prod_pvt); \ req < rsp ? req : rsp; \ }) I would expect to check prod - cons, like RING_HAS_UNCONSUMED_RESPONSES does: #define RING_HAS_UNCONSUMED_RESPONSES(_r) \ ((_r)->sring->rsp_prod - (_r)->rsp_cons) By my understanding, there is no way rsp could be smaller than req, so there is no point having this. Am I missing something? Regards, Zoli