diff options
author | Jan Beulich <jbeulich@suse.com> | 2011-09-07 10:39:59 +0100 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2011-09-07 10:39:59 +0100 |
commit | a704a918ae7818b8f485e5f75e3013d8dcca22ae (patch) | |
tree | e9a259ab0ab9277deaa3e74633e8b217023a393c | |
parent | e75f5779d4a1f53208cf0de6a293aeff0fe86ab4 (diff) | |
download | xen-a704a918ae7818b8f485e5f75e3013d8dcca22ae.tar.gz xen-a704a918ae7818b8f485e5f75e3013d8dcca22ae.tar.bz2 xen-a704a918ae7818b8f485e5f75e3013d8dcca22ae.zip |
bitmap_scnlistprintf() should always zero-terminate its output buffer
... as long as it has non-zero size. So far this would not happen if
the passed in CPU mask was empty.
Also fix the comment describing the return value to actually match
reality.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen-unstable changeset: 23820:ba75234a6f56
xen-unstable date: Wed Sep 07 10:36:55 2011 +0100
-rw-r--r-- | xen/common/bitmap.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/xen/common/bitmap.c b/xen/common/bitmap.c index 363572bedb..a34f519359 100644 --- a/xen/common/bitmap.c +++ b/xen/common/bitmap.c @@ -363,9 +363,8 @@ static inline int bscnl_emit(char *buf, int buflen, int rbot, int rtop, int len) * the range. Output format is compatible with the format * accepted as input by bitmap_parselist(). * - * The return value is the number of characters which would be - * generated for the given input, excluding the trailing '\0', as - * per ISO C99. + * The return value is the number of characters which were output, + * excluding the trailing '\0'. */ int bitmap_scnlistprintf(char *buf, unsigned int buflen, const unsigned long *maskp, int nmaskbits) @@ -383,6 +382,8 @@ int bitmap_scnlistprintf(char *buf, unsigned int buflen, rbot = cur; } } + if (!len && buflen) + *buf = 0; return len; } EXPORT_SYMBOL(bitmap_scnlistprintf); |