From nobody Tue Apr 30 18:00:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1557679903; cv=none; d=zoho.com; s=zohoarc; b=QTvtYO0lvYZVRLxIUDsIrI+ntLzuGFGHFd/to76ZJhzdN6UHE+rh1iOLZTtSVnetWe6+9ig9Q0zuA9av9bwKHwNC1ZbK9uiuEX1YbX186B/0hwoQoKge67sgTBj+W0FlmLLUa3Vz5sxjhOE++tJtvX4vlFgr8zXOJt3ryw8QOfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557679903; h=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:ARC-Authentication-Results; bh=Ebt6rBfRioXzugo4iVq6Vhz0P1s14Wfm0wmZbroY6M0=; b=X0E9AxX1Lh6gFPffsFct5a16NVBmXXZPHkEaV87BTiNa7tVAZouY+n/hvr8+ePcqIPogHz8ieT3VLoH55YSHc63zWBrYluho3jW4CL9JPQdcCjBGtSHNAUQ1mK7ar0u2QEG9Zyy61CnVx+lwqTZ6MJ/4310P/nOXM0ZvoLhaMqo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1557679903197533.0652064801577; Sun, 12 May 2019 09:51:43 -0700 (PDT) Received: from localhost ([127.0.0.1]:45265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPrh0-0000fp-1p for importer@patchew.org; Sun, 12 May 2019 12:51:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPq7z-0003YL-Ox for qemu-devel@nongnu.org; Sun, 12 May 2019 11:11:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPq7x-0006I0-N1 for qemu-devel@nongnu.org; Sun, 12 May 2019 11:11:02 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:45298) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPq7u-0006Aa-Gx; Sun, 12 May 2019 11:10:58 -0400 Received: by mail-pl1-x643.google.com with SMTP id a5so5114082pls.12; Sun, 12 May 2019 08:10:55 -0700 (PDT) Received: from LEGENDTANG-MB0.ust.hk (wf120-214.ust.hk. [175.159.120.214]) by smtp.googlemail.com with ESMTPSA id v66sm7533220pfa.38.2019.05.12.08.10.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 12 May 2019 08:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ebt6rBfRioXzugo4iVq6Vhz0P1s14Wfm0wmZbroY6M0=; b=eO2KUUE6D4fgHyQyg57EYPfd+EhrlMSrIqDxhEkSDV7yrvaqgQmHPbqIYl54IRvnuM H+rxL17QlBu/nkwqSUeASrM9Vqj5w7O9KXrYuI1OW6tgDfI+hv8bBzKu57TJ0fp/leEQ 9M4KZEfHgtTvOeC+G4eEilDHYBt1oml1AtNjeSbC5YCxgmIjM5s3ZpeeulCqTncqT4wb 6kXl9bj3I1iX+uVBS449DVw6fazRSYzueece4hE7H7ar+rNNblLtwo3NzL39x5DyYriT ugNR/fJk2brRhlVnpskQoTksDXIWtfqZ5Au76UZMNgUaDObqwcZQttlcI0izEhZKGoq5 Emjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ebt6rBfRioXzugo4iVq6Vhz0P1s14Wfm0wmZbroY6M0=; b=SzZO71rnCtsDlmYio6ga3e0dJ2xNHYBOeIXxZAHURS3vTuub8y2hZ+wQLB7GIKOkV8 kEv9zS9IjVkFZJ5dL1OAA+WNC6kWQp30+qAjHt4ecYCN1yDLAFV4HGFPTu7aMQ68MQ33 3rukwtS+F5ZG8ZA/gJ2SlZJw24UVQsjyJqNFeXZYbBL8Svz1o+6AJOmRH7eL/hcN7psq fmv4WNO41NEA3B1ysGbXQw7SlV2cj7q2vUMTLIFaTevOiMh5MjjRgmDpjImOOg9khhwG /kiAvPTrUDXM4WbH7yNxnJb0F9jXWLn7rHKvq0DTWMg1JpuAruRdNqse+VustU1/+z5z HXGw== X-Gm-Message-State: APjAAAXgoopHSC91FEiIClHHH1g6/ArMiBlZ+pJ8vTDEOxK2iYpvHbud Nr2NsSPMSnfh2Zo8wqGoVNn5/RkvtlGq6KaJ X-Google-Smtp-Source: APXvYqxTJXlZ8c/E4KS2V2dnXWN/Nu47w23zjAjsnltpPAxYD9RttA9k/otn+PFDp1AT5f0EwWYb/Q== X-Received: by 2002:a17:902:aa5:: with SMTP id 34mr25718171plp.263.1557673853989; Sun, 12 May 2019 08:10:53 -0700 (PDT) From: Wensheng Tang To: qemu-block@nongnu.org Date: Sun, 12 May 2019 23:10:48 +0800 Message-Id: <20190512151048.72412-1-sp3478@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 X-Mailman-Approved-At: Sun, 12 May 2019 12:47:49 -0400 Subject: [Qemu-devel] [PATCH] block: Make block error codes consistent X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Wensheng Tang , "open list:All patches CC here" , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We should keep the error handling consistent. ENOMEDIUM is more meaningful = than ENOENT a when driver cannot be loaded. --- block.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 5c2c6aa..6685be7 100644 --- a/block.c +++ b/block.c @@ -770,7 +770,7 @@ static int find_image_format(BlockBackend *file, const = char *filename, if (!drv) { error_setg(errp, "Could not determine image format: No compatible " "driver found"); - ret =3D -ENOENT; + ret =3D -ENOMEDIUM; } *pdrv =3D drv; return ret; @@ -1619,7 +1619,7 @@ static int bdrv_fill_options(QDict **options, const c= har *filename, drv =3D bdrv_find_format(drvname); if (!drv) { error_setg(errp, "Unknown driver '%s'", drvname); - return -ENOENT; + return -ENOMEDIUM; } /* If the user has explicitly specified the driver, this choice sh= ould * override the BDRV_O_PROTOCOL flag */ @@ -1655,7 +1655,7 @@ static int bdrv_fill_options(QDict **options, const c= har *filename, if (filename) { drv =3D bdrv_find_protocol(filename, parse_filename, errp); if (!drv) { - return -EINVAL; + return -ENOMEDIUM; } =20 drvname =3D drv->format_name; --=20 2.20.1 (Apple Git-117)