[gvfs/nfs] Address first set of review comments
- From: Ross Lagerwall <rossl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/nfs] Address first set of review comments
- Date: Sun, 23 Nov 2014 21:39:09 +0000 (UTC)
commit 0fd34688b79daa0dc4fb5f425da6b50c488a8a59
Author: Ross Lagerwall <rosslagerwall gmail com>
Date: Sat Nov 22 22:31:32 2014 +0000
Address first set of review comments
common/Makefile.am | 1 +
common/gvfsutils.c | 42 ++++++++++++++++++++++++++++++++++++++++++
common/gvfsutils.h | 30 ++++++++++++++++++++++++++++++
daemon/gvfsbackendafp.c | 2 +-
daemon/gvfsbackendsftp.c | 2 +-
daemon/gvfsbackendsmb.c | 9 +++++----
daemon/gvfsdaemon.c | 1 +
daemon/gvfsdaemonutils.c | 17 -----------------
daemon/gvfsdaemonutils.h | 4 +---
metadata/Makefile.am | 6 +++---
metadata/metatree.c | 29 +++--------------------------
11 files changed, 88 insertions(+), 55 deletions(-)
---
diff --git a/common/Makefile.am b/common/Makefile.am
index cfc1c23..00726ee 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -27,6 +27,7 @@ libgvfscommon_la_SOURCES = \
gvfsdaemonprotocol.c gvfsdaemonprotocol.h \
gvfsicon.h gvfsicon.c \
gvfsfileinfo.c gvfsfileinfo.h \
+ gvfsutils.c gvfsutils.h \
$(dbus_built_sources) \
$(NULL)
diff --git a/common/gvfsutils.c b/common/gvfsutils.c
new file mode 100644
index 0000000..87718f3
--- /dev/null
+++ b/common/gvfsutils.c
@@ -0,0 +1,42 @@
+/* GIO - GLib Input, Output and Streaming Library
+ *
+ * Copyright (C) 2014 Ross Lagerwall
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include <string.h>
+#include <glib.h>
+#include "gvfsutils.h"
+
+/**
+ * gvfs_randomize_string:
+ * @str: the string to randomize
+ * @len: the length of the string
+ *
+ * Takes a string and fills it with @len random chars.
+ **/
+void
+gvfs_randomize_string (char *str,
+ int len)
+{
+ int i;
+ const char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+ for (i = 0; i < len; i++)
+ str[i] = chars[g_random_int_range (0, strlen(chars))];
+}
diff --git a/common/gvfsutils.h b/common/gvfsutils.h
new file mode 100644
index 0000000..aa7faf5
--- /dev/null
+++ b/common/gvfsutils.h
@@ -0,0 +1,30 @@
+/* GIO - GLib Input, Output and Streaming Library
+ *
+ * Copyright (C) 2014 Ross Lagerwall
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __G_VFS_UTILS_H__
+#define __G_VFS_UTILS_H__
+
+G_BEGIN_DECLS
+
+void gvfs_randomize_string (char *str,
+ int len);
+
+G_END_DECLS
+
+#endif /* __G_VFS_UTILS_H__ */
diff --git a/daemon/gvfsbackendafp.c b/daemon/gvfsbackendafp.c
index f7cbd5b..090d1de 100644
--- a/daemon/gvfsbackendafp.c
+++ b/daemon/gvfsbackendafp.c
@@ -53,7 +53,7 @@
#include "gvfsjobsetdisplayname.h"
#include "gvfsjobmove.h"
#include "gvfsjobcopy.h"
-#include "gvfsdaemonutils.h"
+#include "gvfsutils.h"
#include "gvfsafpserver.h"
#include "gvfsafpvolume.h"
diff --git a/daemon/gvfsbackendsftp.c b/daemon/gvfsbackendsftp.c
index 0134032..29a841e 100644
--- a/daemon/gvfsbackendsftp.c
+++ b/daemon/gvfsbackendsftp.c
@@ -66,7 +66,7 @@
#include "gvfsjobpush.h"
#include "gvfsjobpull.h"
#include "gvfsdaemonprotocol.h"
-#include "gvfsdaemonutils.h"
+#include "gvfsutils.h"
#include "gvfskeyring.h"
#include "sftp.h"
#include "pty_open.h"
diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c
index 7334ddf..d2b958f 100644
--- a/daemon/gvfsbackendsmb.c
+++ b/daemon/gvfsbackendsmb.c
@@ -50,6 +50,7 @@
#include "gvfsjobenumerate.h"
#include "gvfsdaemonprotocol.h"
#include "gvfsdaemonutils.h"
+#include "gvfsutils.h"
#include "gvfskeyring.h"
#include <libsmbclient.h>
@@ -860,8 +861,8 @@ do_seek_on_read (GVfsBackend *backend,
if ((whence = gvfs_seek_type_to_lseek (type)) == -1)
{
g_vfs_job_failed (G_VFS_JOB (job),
- G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Unsupported seek type"));
+ G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("Unsupported seek type"));
return;
}
@@ -1339,8 +1340,8 @@ do_seek_on_write (GVfsBackend *backend,
if ((whence = gvfs_seek_type_to_lseek (type)) == -1)
{
g_vfs_job_failed (G_VFS_JOB (job),
- G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Unsupported seek type"));
+ G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("Unsupported seek type"));
return;
}
diff --git a/daemon/gvfsdaemon.c b/daemon/gvfsdaemon.c
index cae2803..235a62a 100644
--- a/daemon/gvfsdaemon.c
+++ b/daemon/gvfsdaemon.c
@@ -38,6 +38,7 @@
#include <gvfsdaemon.h>
#include <gvfsdaemonprotocol.h>
#include <gvfsdaemonutils.h>
+#include <gvfsutils.h>
#include <gvfsjobmount.h>
#include <gvfsjobopenforread.h>
#include <gvfsjobopenforwrite.h>
diff --git a/daemon/gvfsdaemonutils.c b/daemon/gvfsdaemonutils.c
index 50f861d..2be975c 100644
--- a/daemon/gvfsdaemonutils.c
+++ b/daemon/gvfsdaemonutils.c
@@ -217,23 +217,6 @@ gvfs_file_info_populate_content_types (GFileInfo *info,
}
/**
- * gvfs_randomize_string:
- * @str: the string to randomize
- * @len: the length of the string
- *
- * Takes a string and fills it with @len random chars.
- **/
-void
-gvfs_randomize_string (char *str, int len)
-{
- int i;
- const char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
-
- for (i = 0; i < len; i++)
- str[i] = chars[g_random_int_range (0, strlen(chars))];
-}
-
-/**
* gvfs_seek_type_to_lseek:
* @type: the seek type
*
diff --git a/daemon/gvfsdaemonutils.h b/daemon/gvfsdaemonutils.h
index a586a6a..f195136 100644
--- a/daemon/gvfsdaemonutils.h
+++ b/daemon/gvfsdaemonutils.h
@@ -40,9 +40,7 @@ void gvfs_file_info_populate_content_types (GFileInfo *info,
const char *basename,
GFileType type);
-void gvfs_randomize_string (char *str, int len);
-
-int gvfs_seek_type_to_lseek (GSeekType type);
+int gvfs_seek_type_to_lseek (GSeekType type);
G_END_DECLS
diff --git a/metadata/Makefile.am b/metadata/Makefile.am
index e86e1c9..767033e 100644
--- a/metadata/Makefile.am
+++ b/metadata/Makefile.am
@@ -46,16 +46,16 @@ libmetadata_la_SOURCES = \
libmetadata_la_LIBADD = $(GLIB_LIBS) $(UDEV_LIBS)
-meta_ls_LDADD = libmetadata.la
+meta_ls_LDADD = libmetadata.la ../common/libgvfscommon.la
meta_ls_SOURCES = meta-ls.c
meta_set_LDADD = libmetadata.la ../common/libgvfscommon.la
meta_set_SOURCES = meta-set.c
-meta_get_LDADD = libmetadata.la
+meta_get_LDADD = libmetadata.la ../common/libgvfscommon.la
meta_get_SOURCES = meta-get.c
-meta_get_tree_LDADD = libmetadata.la
+meta_get_tree_LDADD = libmetadata.la ../common/libgvfscommon.la
meta_get_tree_SOURCES = meta-get-tree.c
convert_nautilus_metadata_LDADD = libmetadata.la $(LIBXML_LIBS)
diff --git a/metadata/metatree.c b/metadata/metatree.c
index 7b59c4a..1c6e5fd 100644
--- a/metadata/metatree.c
+++ b/metadata/metatree.c
@@ -13,6 +13,7 @@
#include "metabuilder.h"
#include <glib.h>
#include <glib/gstdio.h>
+#include "gvfsutils.h"
#include "crc32.h"
#ifdef HAVE_LIBUDEV
@@ -266,38 +267,14 @@ link_to_tmp (const char *source, char *tmpl)
{
char *XXXXXX;
int count, res;
- static const char letters[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- static const int NLETTERS = sizeof (letters) - 1;
- glong value;
- GTimeVal tv;
- static int counter = 0;
/* find the last occurrence of "XXXXXX" */
XXXXXX = g_strrstr (tmpl, "XXXXXX");
g_assert (XXXXXX != NULL);
- /* Get some more or less random data. */
- g_get_current_time (&tv);
- value = (tv.tv_usec ^ tv.tv_sec) + counter++;
-
- for (count = 0; count < 100; value += 7777, ++count)
+ for (count = 0; count < 100; ++count)
{
- glong v = value;
-
- /* Fill in the random bits. */
- XXXXXX[0] = letters[v % NLETTERS];
- v /= NLETTERS;
- XXXXXX[1] = letters[v % NLETTERS];
- v /= NLETTERS;
- XXXXXX[2] = letters[v % NLETTERS];
- v /= NLETTERS;
- XXXXXX[3] = letters[v % NLETTERS];
- v /= NLETTERS;
- XXXXXX[4] = letters[v % NLETTERS];
- v /= NLETTERS;
- XXXXXX[5] = letters[v % NLETTERS];
-
+ gvfs_randomize_string (XXXXXX, 6);
res = link (source, tmpl);
if (res >= 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]