From patchwork Fri Jul 14 11:12:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 107777 Delivered-To: patches@linaro.org Received: by 10.140.101.44 with SMTP id t41csp751878qge; Fri, 14 Jul 2017 04:12:33 -0700 (PDT) X-Received: by 10.99.185.25 with SMTP id z25mr14181952pge.273.1500030753421; Fri, 14 Jul 2017 04:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500030753; cv=none; d=google.com; s=arc-20160816; b=O3yLtpCecUbIePvA5eFL+Jqh6n0yYY2udYPasKbK1Yrx+DCKCEGJ6vUNwmX0ZlGzby glp9yYQ5aHMj2G3y4GYFY1toOYiOTETK0jcHYlmAu19Sk6vSWIMwasNAmL/IC2p7aL1B wPVvU8plVS43Osj0NqUggCXXhvH4wyc4Jy+MyrE9U70GmWxbZ/XjjUijdzSKbPwDENY8 0JgBO1CwXFrm5bzPlERFtl9GmlPaNCmgkaDXxajkORuKM+0UHDzW40viwRmECuqOwayd YkTpuTSGljnHWwmkgVAoL0Cdi5kQcR6lBPgZ0Vwn3NMQU1UP7QkF3p+imRm5VbYpeyFM i2Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=iO73MbGTTBdRTo7j8fCjjdjhLsMHhez6jISt9NcbYLo=; b=B0GTbDHS9LNyZ8cXVNNunBFyv3EtYVwN+3pSGvDN54bqpLIxury1mJgea/Clfkk0jK T6wcH+cObmO8GC0TAdl55C6WB6syqQou+SAWRk3xkrPnkl0y44JKT1qzvXkOkYFvZswp coNtWml7ZGGlYLDgfJbM/gwuMguPU7hpg7Atj6FIZ60j5P1MFokMKLd6JnwzFKfW2Zz3 t+Mjn1j58VWMUPrJkasTvXL4sgVs+q40opU2USG35flM2EzHt/43WmcXfUC4hEzlC4g1 vvNU1T87RgiJa4tfZ3ULGQUQS7kWywYTQ4rNLQu+FzIpEnZA7FA91ggA+oFLPcOaEIlI lCCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id e5si6547016plj.542.2017.07.14.04.12.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 04:12:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1dVyWI-0007pz-Tj; Fri, 14 Jul 2017 12:12:26 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Samuel Thibault , Jan Kiszka , "Dr . David Alan Gilbert" Subject: [PATCH v2 0/2] slirp: handle errors in sosendoob() Date: Fri, 14 Jul 2017 12:12:23 +0100 Message-Id: <1500030745-10619-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 At the moment the slirp sosendoob() function doesn't properly handle errors from slirp_send(), and its callers don't do anything with its return value either. (Coverity spots the latter as CID 1005633.) This patchset attempts to fix that. In the first patch we fix sosendoob() itself so that we return errors to the caller and treat short writes as reducing the amount of urgent data to be sent. In the second patch we make the call in sowrite() treat any return form sosendoob() which didn't transfer all the urgent data as a "disconnect the socket" error in the same way that it already handles errors for writes of non-urgent data. The call to sosendoob() in sbappend() can safely ignore any failures as in this case sowrite() will be called shortly and will deal with them. Coding style: I've opted to stick with the tab-indent that the slirp code uses rather than reindent to QEMU standard. Happy to go the other way if the maintainer prefers. Changes v1->v2: * since sosendoob() updates so->so_urgc, we need to capture the old value to check that the write has actually written what it is supposed to. thanks -- PMM Peter Maydell (2): slirp: Handle error returns from slirp_send() in sosendoob() slirp: Handle error returns from sosendoob() slirp/sbuf.c | 2 +- slirp/socket.c | 52 +++++++++++++++++++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 18 deletions(-) -- 2.7.4