From 9480074ad85716f33c08fb82d51a8538f89f7f10 Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Mon, 19 Feb 2018 18:45:05 +0900 Subject: [PATCH 1/3] Use ERR_PTR/PTR_ERR for kobj_open_file() return value (If this is good I'll also pr for ZoL which is another consumer of this) Signed-off-by: Tomohiro Kusumi --- module/spl/spl-generic.c | 2 +- module/spl/spl-kobj.c | 4 ++-- module/splat/splat-kobj.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/module/spl/spl-generic.c b/module/spl/spl-generic.c index efd90109..ce5f3167 100644 --- a/module/spl/spl-generic.c +++ b/module/spl/spl-generic.c @@ -556,7 +556,7 @@ hostid_read(uint32_t *hostid) int error; file = kobj_open_file(spl_hostid_path); - if (file == (struct _buf *)-1) + if (PTR_ERR(file) == -1) return (ENOENT); error = kobj_get_filesize(file, &size); diff --git a/module/spl/spl-kobj.c b/module/spl/spl-kobj.c index 7019369b..7057ea1d 100644 --- a/module/spl/spl-kobj.c +++ b/module/spl/spl-kobj.c @@ -35,11 +35,11 @@ kobj_open_file(const char *name) file = kmalloc(sizeof (_buf_t), kmem_flags_convert(KM_SLEEP)); if (file == NULL) - return ((_buf_t *)-1UL); + return (ERR_PTR(-1)); if ((rc = vn_open(name, UIO_SYSSPACE, FREAD, 0644, &vp, 0, 0))) { kfree(file); - return ((_buf_t *)-1UL); + return (ERR_PTR(-1)); } file->vp = vp; diff --git a/module/splat/splat-kobj.c b/module/splat/splat-kobj.c index bd44de39..1c35a19c 100644 --- a/module/splat/splat-kobj.c +++ b/module/splat/splat-kobj.c @@ -46,7 +46,7 @@ splat_kobj_test1(struct file *file, void *arg) struct _buf *f; f = kobj_open_file(SPLAT_KOBJ_TEST_FILE); - if (f == (struct _buf *)-1) { + if (PTR_ERR(f) == -1) { splat_vprint(file, SPLAT_KOBJ_TEST1_NAME, "Failed to open " "test file: %s\n", SPLAT_KOBJ_TEST_FILE); return -ENOENT; @@ -68,7 +68,7 @@ splat_kobj_test2(struct file *file, void *arg) int rc; f = kobj_open_file(SPLAT_KOBJ_TEST_FILE); - if (f == (struct _buf *)-1) { + if (PTR_ERR(f) == -1) { splat_vprint(file, SPLAT_KOBJ_TEST2_NAME, "Failed to open " "test file: %s\n", SPLAT_KOBJ_TEST_FILE); return -ENOENT; From 4bc3286217212f7c3a7e5103f53da637d4af736c Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Mon, 19 Feb 2018 19:23:53 +0900 Subject: [PATCH 2/3] Staticize kstat_default_update() This is only used via ->ks_update of kstat_t*. This isn't exported nor do headers have its prototype. Signed-off-by: Tomohiro Kusumi --- module/spl/spl-kstat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/spl/spl-kstat.c b/module/spl/spl-kstat.c index 70c0c98f..405ece0a 100644 --- a/module/spl/spl-kstat.c +++ b/module/spl/spl-kstat.c @@ -327,7 +327,7 @@ kstat_seq_show(struct seq_file *f, void *p) return (-rc); } -int +static int kstat_default_update(kstat_t *ksp, int rw) { ASSERT(ksp != NULL); From 3157148fca604055ded47ee29a23ee4b4c3ed143 Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Mon, 19 Feb 2018 20:40:38 +0900 Subject: [PATCH 3/3] Fix function name typos vn_init() and vn_fini() had been renamed by 12ff95ff in 2011. Signed-off-by: Tomohiro Kusumi --- module/spl/spl-vnode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c index f019a087..79ca89ee 100644 --- a/module/spl/spl-vnode.c +++ b/module/spl/spl-vnode.c @@ -658,7 +658,7 @@ vn_file_cache_constructor(void *buf, void *cdrarg, int kmflags) INIT_LIST_HEAD(&fp->f_list); return (0); -} /* file_cache_constructor() */ +} /* vn_file_cache_constructor() */ static void vn_file_cache_destructor(void *buf, void *cdrarg) @@ -680,7 +680,7 @@ spl_vn_init(void) vn_file_cache_destructor, NULL, NULL, NULL, 0); return (0); -} /* vn_init() */ +} /* spl_vn_init() */ void spl_vn_fini(void) @@ -703,4 +703,4 @@ spl_vn_fini(void) kmem_cache_destroy(vn_file_cache); kmem_cache_destroy(vn_cache); -} /* vn_fini() */ +} /* spl_vn_fini() */