Assign buf_size before using it

This commit is contained in:
wbaumann 2013-08-10 10:54:58 +00:00
parent f5e14315d4
commit ff7d6e7af2

View File

@ -182,6 +182,15 @@ dav_init_kernel_interface(const char *url, const char *mpoint,
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
"Initializing kernel interface");

buf_size = args->buf_size * 1024;
if (buf_size < (FUSE_MIN_READ_BUFFER + 4096))
buf_size = FUSE_MIN_READ_BUFFER + 4096;
buf = malloc(buf_size);
if (!buf)
error(EXIT_FAILURE, errno, _("can't allocate message buffer"));

idle_time = args->delay_upload;

char *path = xasprintf("%s/%s", DAV_DEV_DIR, FUSE_DEV_NAME);

fuse_device = open(path, O_RDWR | O_NONBLOCK);
@ -211,15 +220,6 @@ dav_init_kernel_interface(const char *url, const char *mpoint,
error(EXIT_FAILURE, errno, _("mounting failed"));

free(mdata);

buf_size = args->buf_size * 1024;
if (buf_size < (FUSE_MIN_READ_BUFFER + 4096))
buf_size = FUSE_MIN_READ_BUFFER + 4096;
buf = malloc(buf_size);
if (!buf)
error(EXIT_FAILURE, errno, _("can't allocate message buffer"));

idle_time = args->delay_upload;
}