Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146956073
D33798.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
990 B
Referenced Files
None
Subscribers
None
D33798.diff
View Options
diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h
--- a/sys/compat/linuxkpi/common/include/linux/kernel.h
+++ b/sys/compat/linuxkpi/common/include/linux/kernel.h
@@ -649,6 +649,37 @@
#define TAINT_WARN 0
#define test_taint(x) (0)
+static inline int
+_h2b(const char c)
+{
+
+ if (c >= '0' && c <= '9')
+ return (c - '0');
+ if (c >= 'a' && c <= 'f')
+ return (10 + c - 'a');
+ if (c >= 'A' && c <= 'F')
+ return (10 + c - 'A');
+ return (-EINVAL);
+}
+
+static inline int
+hex2bin(uint8_t *bindst, const char *hexsrc, size_t binlen)
+{
+ int hi4, lo4;
+
+ while (binlen > 0) {
+ hi4 = _h2b(*hexsrc++);
+ lo4 = _h2b(*hexsrc++);
+ if (hi4 < 0 || lo4 < 0)
+ return (-EINVAL);
+
+ *bindst++ = (hi4 << 4) | lo4;
+ binlen--;
+ }
+
+ return (0);
+}
+
/*
* Checking if an option is defined would be easy if we could do CPP inside CPP.
* The defined case whether -Dxxx or -Dxxx=1 are easy to deal with. In either
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 8, 2:49 AM (54 m, 38 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29392185
Default Alt Text
D33798.diff (990 B)
Attached To
Mode
D33798: LinuxKPI: add hex2bin()
Attached
Detach File
Event Timeline
Log In to Comment