On 10.07.2013 16:57, Ján Tomko wrote:
> From: Wei Zhou <w.zhou(a)leaseweb.com>
>
> Make virStorageBackendVolOpenCheckMode return -2 instead of
> -1 if volume file is missing.
>
>
https://bugzilla.redhat.com/show_bug.cgi?id=977706
> ---
> src/storage/storage_backend.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
> index e2527c9..f063601 100644
> --- a/src/storage/storage_backend.c
> +++ b/src/storage/storage_backend.c
> @@ -1084,7 +1084,7 @@ virStorageBackendForType(int type)
> * Allows caller to silently ignore files with improper mode
> *
> * Returns -1 on error, -2 if file mode is unexpected or the
> - * volume is a dangling symbolic link.
> + * volume is a dangling symbolic link or file is missing.
> */
> int
> virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
> @@ -1097,7 +1097,7 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned
int flags)
> virReportSystemError(errno,
> _("cannot stat file '%s'"),
> path);
If we want to *silently* ignore missing file, why do we
virReportSystemError() here?
> - return -1;
> + return -2;
> }
Well returning -1 vs -2 from this function isn't ignoring the
error. It is just providing the caller a way to detect a specific
error scenario. Thus if the caller decides to ignore the error
when ret == -2, then the caller should call virResetLastError()
to clear it.
Daniel
--
|: