Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147899195
D51723.1784727777.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D51723.1784727777.diff
View Options
diff --git a/lib/libutil/expand_number.c b/lib/libutil/expand_number.c
--- a/lib/libutil/expand_number.c
+++ b/lib/libutil/expand_number.c
@@ -33,10 +33,12 @@
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
-#include <libutil.h>
#include <stdbool.h>
#include <stdint.h>
+#include <libutil.h>
+#undef expand_number
+
int
expand_number(const char *buf, int64_t *num)
{
@@ -146,3 +148,19 @@
return (0);
}
+
+int
+expand_unsigned(const char *buf, uint64_t *nump)
+{
+ int64_t num;
+ int ret;
+
+ if ((ret = expand_number(buf, &num)) < 0)
+ return (ret);
+ if (num < 0) {
+ errno = ERANGE;
+ return (-1);
+ }
+ *nump = (uint64_t)num;
+ return (0);
+}
diff --git a/lib/libutil/libutil.h b/lib/libutil/libutil.h
--- a/lib/libutil/libutil.h
+++ b/lib/libutil/libutil.h
@@ -88,7 +88,12 @@
__BEGIN_DECLS
void clean_environment(const char * const *_white,
const char * const *_more_white);
+int expand_unsigned(const char *_buf, uint64_t *_num);
int expand_number(const char *_buf, int64_t *_num);
+#define expand_number(_buf, _num) \
+ _Generic((_num), \
+ uint64_t *: expand_unsigned, \
+ default: expand_number)((_buf), (_num))
int extattr_namespace_to_string(int _attrnamespace, char **_string);
int extattr_string_to_namespace(const char *_string, int *_attrnamespace);
int flopen(const char *_path, int _flags, ...);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jul 22, 1:42 PM (10 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29228060
Default Alt Text
D51723.1784727777.diff (1 KB)
Attached To
Mode
D51723: libutil: Backward compatibility for expand_number()
Attached
Detach File
Event Timeline
Log In to Comment