virtiofsd: Save error code early at the failure callsite
commit1e08f164e9fdc9528ad6990012301b9a04b0bc90
authorVivek Goyal <vgoyal@redhat.com>
Mon, 8 Feb 2021 22:40:23 +0000 (8 17:40 -0500)
committerDr. David Alan Gilbert <dgilbert@redhat.com>
Tue, 16 Feb 2021 17:03:09 +0000 (16 17:03 +0000)
tree03c972153ca2c3881af524ddcff16bd0476ddbe7
parenta65963efa3a8533e8c9fc62e899147612d913058
virtiofsd: Save error code early at the failure callsite

Change error code handling slightly in lo_setattr(). Right now we seem
to jump to out_err and assume that "errno" is valid and use that to
send reply.

But if caller has to do some other operations before jumping to out_err,
then it does the dance of first saving errno to saverr and the restore
errno before jumping to out_err. This makes it more confusing.

I am about to make more changes where caller will have to do some
work after error before jumping to out_err. I found it easier to
change the convention a bit. That is caller saves error in "saverr"
before jumping to out_err. And out_err uses "saverr" to send error
back and does not rely on "errno" having actual error.

v3: Resolved conflicts in lo_setattr() due to lo_inode_open() changes.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20210208224024.43555-2-vgoyal@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
tools/virtiofsd/passthrough_ll.c