qed: Fix static checker warning
[linux/fpc-iii.git] / tools / perf / trace / beauty / pkey_alloc.c
blob2ba784a3734adb2fd7088016970c627a508511f8
1 /*
2 * trace/beauty/pkey_alloc.c
4 * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
6 * Released under the GPL v2. (and only v2, not any later version)
7 */
9 #include "trace/beauty/beauty.h"
10 #include <linux/kernel.h>
11 #include <linux/log2.h>
13 static size_t pkey_alloc__scnprintf_access_rights(int access_rights, char *bf, size_t size)
15 int i, printed = 0;
17 #include "trace/beauty/generated/pkey_alloc_access_rights_array.c"
18 static DEFINE_STRARRAY(pkey_alloc_access_rights);
20 if (access_rights == 0) {
21 const char *s = strarray__pkey_alloc_access_rights.entries[0];
22 if (s)
23 return scnprintf(bf, size, "%s", s);
24 return scnprintf(bf, size, "%d", 0);
27 for (i = 1; i < strarray__pkey_alloc_access_rights.nr_entries; ++i) {
28 int bit = 1 << (i - 1);
30 if (!(access_rights & bit))
31 continue;
33 if (printed != 0)
34 printed += scnprintf(bf + printed, size - printed, "|");
36 if (strarray__pkey_alloc_access_rights.entries[i] != NULL)
37 printed += scnprintf(bf + printed, size - printed, "%s", strarray__pkey_alloc_access_rights.entries[i]);
38 else
39 printed += scnprintf(bf + printed, size - printed, "0x%#", bit);
42 return printed;
45 size_t syscall_arg__scnprintf_pkey_alloc_access_rights(char *bf, size_t size, struct syscall_arg *arg)
47 unsigned long cmd = arg->val;
49 return pkey_alloc__scnprintf_access_rights(cmd, bf, size);