emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 60af986f38: Clean up failable requests in more places


From: Po Lu
Subject: master 60af986f38: Clean up failable requests in more places
Date: Wed, 29 Jun 2022 03:09:29 -0400 (EDT)

branch: master
commit 60af986f38e98fde3e17005e49d175c061a1a29a
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Clean up failable requests in more places
    
    * lisp/term/haiku-win.el (haiku-get-numeric-enum): Fix build.
    
    * src/xterm.c (x_clean_failable_requests): Avoid redundant
    memcpy if first == last.
    (x_ignore_errors_for_next_request): Fix check for last request.
    (x_check_errors, x_had_errors_p): Clean up failable requests
    here.
---
 lisp/term/haiku-win.el | 39 ++++++++++++++++++++-------------------
 src/xterm.c            | 22 +++++++++++++++++++---
 2 files changed, 39 insertions(+), 22 deletions(-)

diff --git a/lisp/term/haiku-win.el b/lisp/term/haiku-win.el
index f73c8b7125..f6e4829cad 100644
--- a/lisp/term/haiku-win.el
+++ b/lisp/term/haiku-win.el
@@ -174,25 +174,26 @@ VALUE as a unibyte string, or nil if VALUE was not a 
string."
                                           (insert "\n")))
                             (buffer-string))))))
 
-(defun haiku-get-numeric-enum (name)
-  "Return the numeric value of the system enumerator NAME."
-  (or (get name 'haiku-numeric-enum)
-      (let ((value 0)
-            (offset 0)
-            (string (symbol-name name)))
-        (cl-loop for octet across string
-                 do (progn
-                      (when (or (< octet 0)
-                                (> octet 255))
-                        (error "Out of range octet: %d" octet))
-                      (setq value
-                            (logior value
-                                    (lsh octet
-                                         (- (* (1- (length string)) 8)
-                                            offset))))
-                      (setq offset (+ offset 8))))
-        (prog1 value
-          (put name 'haiku-enumerator-id value)))))
+(eval-and-compile
+  (defun haiku-get-numeric-enum (name)
+    "Return the numeric value of the system enumerator NAME."
+    (or (get name 'haiku-numeric-enum)
+        (let ((value 0)
+              (offset 0)
+              (string (symbol-name name)))
+          (cl-loop for octet across string
+                   do (progn
+                        (when (or (< octet 0)
+                                  (> octet 255))
+                          (error "Out of range octet: %d" octet))
+                        (setq value
+                              (logior value
+                                      (lsh octet
+                                           (- (* (1- (length string)) 8)
+                                              offset))))
+                        (setq offset (+ offset 8))))
+          (prog1 value
+            (put name 'haiku-enumerator-id value))))))
 
 (defmacro haiku-numeric-enum (name)
   "Expand to the numeric value NAME as a system identifier."
diff --git a/src/xterm.c b/src/xterm.c
index 7298feb43a..33c8d4199e 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -23010,8 +23010,9 @@ x_clean_failable_requests (struct x_display_info 
*dpyinfo)
        break;
     }
 
-  memmove (&dpyinfo->failable_requests, first,
-          sizeof *first * (last - first));
+  if (first != last)
+    memmove (&dpyinfo->failable_requests, first,
+            sizeof *first * (last - first));
 
   dpyinfo->next_failable_request = (dpyinfo->failable_requests
                                    + (last - first));
@@ -23025,7 +23026,7 @@ x_ignore_errors_for_next_request (struct x_display_info 
*dpyinfo)
   request = dpyinfo->next_failable_request;
   max = dpyinfo->failable_requests + N_FAILABLE_REQUESTS;
 
-  if (request > max)
+  if (request >= max)
     {
       /* There is no point in making this extra sync if all requests
         are known to have been fully processed.  */
@@ -23119,6 +23120,7 @@ x_uncatch_errors (void)
 void
 x_check_errors (Display *dpy, const char *format)
 {
+  struct x_display_info *dpyinfo;
   char *string;
 
   /* This shouldn't happen, since x_check_errors should be called
@@ -23134,6 +23136,12 @@ x_check_errors (Display *dpy, const char *format)
          > x_error_message->first_request))
     XSync (dpy, False);
 
+  dpyinfo = x_display_info_for_display (dpy);
+
+  /* Clean the array of failable requests, since a sync happened.  */
+  if (dpyinfo)
+    x_clean_failable_requests (dpyinfo);
+
   if (x_error_message->string)
     {
       string = alloca (strlen (x_error_message->string) + 1);
@@ -23149,6 +23157,8 @@ x_check_errors (Display *dpy, const char *format)
 bool
 x_had_errors_p (Display *dpy)
 {
+  struct x_display_info *dpyinfo;
+
   /* This shouldn't happen, since x_check_errors should be called
      immediately inside an x_catch_errors block.  */
   if (dpy != x_error_message->dpy)
@@ -23161,6 +23171,12 @@ x_had_errors_p (Display *dpy)
          > x_error_message->first_request))
     XSync (dpy, False);
 
+  dpyinfo = x_display_info_for_display (dpy);
+
+  /* Clean the array of failable requests, since a sync happened.  */
+  if (dpyinfo)
+    x_clean_failable_requests (dpyinfo);
+
   return !!x_error_message->string;
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]