vfs_fruit: fix possible uninitialized use
[obnox/samba/samba-obnox.git] / source3 / modules / vfs_fruit.c
index 0441d5ebd48501fb969fa76f14ed0e512d1d6709..dd40490984724e22b8ad36974f1c6bba17f13cd5 100644 (file)
@@ -755,11 +755,14 @@ static ssize_t ad_header_read_rsrc(struct adouble *ad, const char *path)
        struct adouble *meta_ad = NULL;
        SMB_STRUCT_STAT sbuf;
        bool ok;
-       int saved_errno;
+       int saved_errno = 0;
 
        SMB_VFS_HANDLE_GET_DATA(ad->ad_handle, config,
                                struct fruit_config_data, return -1);
 
+       /* Try rw first so we can use the fd in ad_convert() */
+       mode = O_RDWR;
+
        if (ad->ad_fsp && ad->ad_fsp->fh && (ad->ad_fsp->fh->fd != -1)) {
                fd = ad->ad_fsp->fh->fd;
        } else {
@@ -772,9 +775,6 @@ static ssize_t ad_header_read_rsrc(struct adouble *ad, const char *path)
                        }
                }
 
-               /* Try rw first so we can use the fd in ad_convert() */
-               mode = O_RDWR;
-
        retry:
                if (config->rsrc == FRUIT_RSRC_XATTR) {
 #ifndef HAVE_ATTROPEN