On Tue, Jun 19, 2012 at 05:27:11AM +0000, Poul-Henning Kamp wrote:
> In message <68fbe843-7337-4c90-b01f-e0caabb62...@gsoft.com.au>, "Daniel 
> O'Conno
> r" writes:
> 
> >> If size is odd, this does not copy the last byte. Not sure, whether =
> >this is intended.
> 
> Feel free to improve...

Index: fbreg.h
===================================================================
--- fbreg.h	(revision 237289)
+++ fbreg.h	(working copy)
@@ -39,9 +39,12 @@
 static __inline void
 copyw(uint16_t *src, uint16_t *dst, size_t size)
 {
+	const int is_odd = (size & 0x1);
 	size >>= 1;
 	while (size--)
 		*dst++ = *src++;
+	if (is_odd)
+		*(char*)dst = *(char*)src; // copy last byte
 }
 #define bcopy_io(s, d, c)	copyw((void*)(s), (void*)(d), (c))
 #define bcopy_toio(s, d, c)	copyw((void*)(s), (void*)(d), (c))
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to