Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F140125219
D31638.id94145.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
713 B
Referenced Files
None
Subscribers
None
D31638.id94145.diff
View Options
Index: lib/libc/string/swab.c
===================================================================
--- lib/libc/string/swab.c
+++ lib/libc/string/swab.c
@@ -43,15 +43,16 @@
void
swab(const void * __restrict from, void * __restrict to, ssize_t len)
{
- unsigned long temp;
- int n;
- char *fp, *tp;
+ unsigned char temp;
+ size_t n;
+ const unsigned char *fp;
+ unsigned char *tp;
- if (len <= 0)
+ if (len < 2) // needs to be at least 2 to work
return;
- n = len >> 1;
- fp = (char *)from;
- tp = (char *)to;
+ n = (size_t)len >> 1;
+ fp = (const unsigned char *)from;
+ tp = (unsigned char *)to;
#define STEP temp = *fp++,*tp++ = *fp++,*tp++ = temp
/* round to multiple of 8 */
for (; n & 0x7; --n)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 21, 2:13 PM (11 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27114056
Default Alt Text
D31638.id94145.diff (713 B)
Attached To
Mode
D31638: [libc] Optimize swab so that it can handle any ssize_t value
Attached
Detach File
Event Timeline
Log In to Comment