public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: clipboard: Make intent of the code clearer.
@ 2021-12-11 14:26 Takashi Yano
  0 siblings, 0 replies; only message in thread
From: Takashi Yano @ 2021-12-11 14:26 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=72175bbd28f65dc3dea875183b9c430018a3400c

commit 72175bbd28f65dc3dea875183b9c430018a3400c
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Wed Dec 8 20:59:05 2021 +0900

    Cygwin: clipboard: Make intent of the code clearer.

Diff:
---
 winsup/cygwin/fhandler_clipboard.cc   | 4 ++--
 winsup/cygwin/include/sys/clipboard.h | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/fhandler_clipboard.cc b/winsup/cygwin/fhandler_clipboard.cc
index 05f54ffb3..14820701c 100644
--- a/winsup/cygwin/fhandler_clipboard.cc
+++ b/winsup/cygwin/fhandler_clipboard.cc
@@ -76,7 +76,7 @@ fhandler_dev_clipboard::set_clipboard (const void *buf, size_t len)
       clipbuf->cb_sec  = clipbuf->ts.tv_sec;
 #endif
       clipbuf->cb_size = len;
-      memcpy (&clipbuf[1], buf, len); // append user-supplied data
+      memcpy (clipbuf->cb_data, buf, len); // append user-supplied data
 
       GlobalUnlock (hmem);
       EmptyClipboard ();
@@ -229,7 +229,7 @@ fhandler_dev_clipboard::read (void *ptr, size_t& len)
       if (pos < (off_t) clipbuf->cb_size)
 	{
 	  ret = (len > (clipbuf->cb_size - pos)) ? clipbuf->cb_size - pos : len;
-	  memcpy (ptr, (char *) (clipbuf + 1) + pos, ret);
+	  memcpy (ptr, clipbuf->cb_data + pos, ret);
 	  pos += ret;
 	}
     }
diff --git a/winsup/cygwin/include/sys/clipboard.h b/winsup/cygwin/include/sys/clipboard.h
index 4c00c8ea1..932fe98d9 100644
--- a/winsup/cygwin/include/sys/clipboard.h
+++ b/winsup/cygwin/include/sys/clipboard.h
@@ -44,6 +44,7 @@ typedef struct
     };
   };
   uint64_t      cb_size; // 8 bytes everywhere
+  char          cb_data[];
 } cygcb_t;
 
 #endif


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-11 14:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-11 14:26 [newlib-cygwin] Cygwin: clipboard: Make intent of the code clearer Takashi Yano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).