Re: linux-next: build warning after merge of the vfs-brauner tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 05, 2024 at 08:47:40PM -0800, Linus Torvalds wrote:
> On Tue, 5 Mar 2024 at 20:37, Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx> wrote:
> >
> > +static struct page *dump_page_copy(struct page *src, struct page *dst)
> > +{
> > +        return NULL;
> > +}
> 
> No, it needs to be "return src;" not NULL.
> 
> That
> 
>   #define dump_page_copy(src, dst) ((dst), (src))
> 
> was supposed to be a "use 'dst', return 'src'" macro, and is correct
> as that. The problem - as you noticed - is that it causes that "left
> side of comma expression has no effect" warning.
> 
> (Technically it *does* have an effect - exactly the "argument is used"
> one - but the compiler warning does make sense).
> 
> Actually, the simplest thing to do is probably just
> 
>   #define dump_page_free(x) ((void)(x))
>   #define dump_page_copy(src, dst) (src)
> 
> where the "use" of the 'dump_page' argument is that dump_page_free()
> void cast, and dump_page_copy() simply doesn't need to use it at all.
> 
> Christian?

I would just do it like Stephen did (but returning src ofc) because it's
symmetric to the #ifdef copy_mc_to_kernel definition of dump_page_copy()
and seems easier to read to me.

But I honestly don't care too much. So I'd pick Stephen's change and if
you prefer to do it differently just change it when I send you the pr.

+/*
+ * If we might get machine checks from kernel accesses during the
+ * core dump, let's get those errors early rather than during the
+ * IO. This is not performance-critical enough to warrant having
+ * all the machine check logic in the iovec paths.
+ */
+#ifdef copy_mc_to_kernel
+
+#define dump_page_alloc() alloc_page(GFP_KERNEL)
+#define dump_page_free(x) __free_page(x)
+static struct page *dump_page_copy(struct page *src, struct page *dst)
+{
+       void *buf = kmap_local_page(src);
+       size_t left = copy_mc_to_kernel(page_address(dst), buf, PAGE_SIZE);
+       kunmap_local(buf);
+       return left ? NULL : dst;
+}
+
+#else
+
+/* We just want to return non-NULL; it's never used. */
+#define dump_page_alloc() ERR_PTR(-EINVAL)
+#define dump_page_free(x) ((void)(x))
+static inline struct page *dump_page_copy(struct page *src, struct page *dst)
+{
+       return src;
+}
+#endif




[Index of Archives]     [Linux Kernel]     [Linux USB Development]     [Yosemite News]     [Linux SCSI]

  Powered by Linux