Re: + procfs-add-vmflags-field-in-smaps-output-v3-fix-2.patch addedto -mm tree

From: Stephen Rothwell
Date: Wed Oct 24 2012 - 05:47:52 EST


Hi Cyrill,

On Wed, 24 Oct 2012 12:45:15 +0400 Cyrill Gorcunov <gorcunov@xxxxxxxxxx> wrote:
>
> static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
> {
> +#define __VM_FLAG(_f, _s) [ilog2(_f)] = {(const char [2]){_s}}

I really don't think you need the cast (and it may hide bad usages) or
the second set of braces. Thus:

#define __VM_FLAG(_f, _s) [ilog2(_f)] = {_s}

> +
> /*
> * Don't forget to update Documentation/ on changes.
> */
> @@ -491,46 +493,49 @@ static void show_smap_vma_flags(struct s
> /*
> * In case if we meet a flag we don't know about.
> */
> - [0 ... (BITS_PER_LONG-1)] = { {'?', '?'} },
> + [0 ... (BITS_PER_LONG-1)] = { (const char [2]){"??"} },

And here.

Further is there any reason for the struct?

#define __VM_FLAG(_f, _s) [ilog2(_f)] = _s

static const char mnemonics[BITS_PER_LONG][2] = {
...
};

> seq_puts(m, "VmFlags: ");
> for (i = 0; i < BITS_PER_LONG; i++) {
> - if (vma->vm_flags & (1 << i))
> + if (vma->vm_flags & (1ul << i)) {
> seq_printf(m, "%c%c ",
> mnemonics[i].l[0],
> mnemonics[i].l[1]);

mnemonics[i][0], mnemonics[i][1]

/me looks for another bike shed :-)
--
Cheers,
Stephen Rothwell sfr@xxxxxxxxxxxxxxxx

Attachment: pgp00000.pgp
Description: PGP signature