ATTRIBUTE_FORMAT((printf, 2, 0));
extern void printaddr_ull(unsigned long long);
-extern void printxvals(const uint64_t, const char *, const struct xlat *, ...)
+extern int printxvals(const uint64_t, const char *, const struct xlat *, ...)
ATTRIBUTE_SENTINEL;
-extern void printxval_searchn(const struct xlat *xlat, size_t xlat_size,
+extern int printxval_searchn(const struct xlat *xlat, size_t xlat_size,
uint64_t val, const char *dflt);
#define printxval_search(xlat__, val__, dflt__) \
printxval_searchn(xlat__, ARRAY_SIZE(xlat__), val__, dflt__)
return printflags64(x, flags, dflt);
}
-static inline void
+static inline int
printxval64(const struct xlat *x, const uint64_t val, const char *dflt)
{
- printxvals(val, dflt, x, NULL);
+ return printxvals(val, dflt, x, NULL);
}
-static inline void
+static inline int
printxval(const struct xlat *x, const unsigned int val, const char *dflt)
{
- printxvals(val, dflt, x, NULL);
+ return printxvals(val, dflt, x, NULL);
}
-static inline void
+static inline int
printxval_long(const struct xlat *x, const unsigned long val, const char *dflt)
{
- printxvals(val, dflt, x, NULL);
+ return printxvals(val, dflt, x, NULL);
}
#ifdef ALPHA
pos++;
}
}
-/*
+
+/**
* Print entry in struct xlat table, if there.
+ *
+ * @param val Value to search a literal representation for.
+ * @param dflt String (abbreviated in comment syntax) which should be emitted
+ * if no appropriate xlat value has been found.
+ * @param xlat (And the following arguments) Pointers to arrays of xlat values.
+ * The last argument should be NULL.
+ * @return 1 if appropriate xlat value has been found, 0 otherwise.
*/
-void
+int
printxvals(const uint64_t val, const char *dflt, const struct xlat *xlat, ...)
{
va_list args;
if (str) {
tprints(str);
va_end(args);
- return;
+ return 1;
}
}
/* No hits -- print raw # instead. */
tprintf(" /* %s */", dflt);
va_end(args);
+
+ return 0;
}
-/*
+/**
* Print entry in sorted struct xlat table, if it is there.
+ *
+ * @param xlat Pointer to an array of xlat values (not terminated with
+ * XLAT_END).
+ * @param xlat_size Number of xlat elements present in array (usually ARRAY_SIZE
+ * if array is declared in the unit's scope and not
+ * terminated with XLAT_END).
+ * @param val Value to search literal representation for.
+ * @param dflt String (abbreviated in comment syntax) which should be
+ * emitted if no appropriate xlat value has been found.
+ * @return 1 if appropriate xlat value has been found, 0
+ * otherwise.
*/
-void
+int
printxval_searchn(const struct xlat *xlat, size_t xlat_size, uint64_t val,
const char *dflt)
{
if (s) {
tprints(s);
- } else {
- tprintf("%#" PRIx64, val);
- if (dflt)
- tprintf(" /* %s */", dflt);
+ return 1;
}
+
+ tprintf("%#" PRIx64, val);
+ if (dflt)
+ tprintf(" /* %s */", dflt);
+
+ return 0;
}
/*