Fix various problems encountered

* egl.c (AddShmFormat): Fix coding style.
* explicit_synchronization.c (HandleSurfaceCommit): Remove
redundant NULL check.
* run.c (RunStep): Flush clients after completing selection
transfers.  Fix sizeof when allocating pollfds.
* seat.c (CancelResizeOperation): Avoid NULL-pointer dereference
when subcompositor is not specified.
* shm.c (DereferencePool, CreatePool): Remove redundant checks
of pool->size; it can never be zero.
* subsurface.c (Setup): Remove redundant NULL check.
* text_input.c (SetCursorRectangle): Fix some statements.
(FindTextSections, EncodeIMString, CheckStyles, ConvertString)
(PreeditString, CommitString): Fix usage of format modifiers in
debug trace code.
* xdata.c (HandleSelectionNotify): Use selection time, not event
time.
* xdg_popup.c (MoveWindow, InternalReposition): Remove various
redundant checks.
This commit is contained in:
hujianwei 2022-10-22 07:13:21 +00:00
parent c4f2e07a4b
commit 3fe08b5c7c
9 changed files with 33 additions and 40 deletions

4
egl.c
View file

@ -2110,8 +2110,8 @@ static void
AddShmFormat (uint32_t format)
{
shm_formats
= XLRealloc (shm_formats,
sizeof *shm_formats * ++n_shm_formats);
= XLRealloc (shm_formats, (sizeof *shm_formats
* ++n_shm_formats));
shm_formats[n_shm_formats - 1].format = format;
}

View file

@ -248,8 +248,7 @@ HandleSurfaceCommit (Synchronization *synchronization, Surface *surface)
surface. */
surface->release->surface = surface;
if (surface->release
&& !(surface->pending_state.pending & PendingBuffer
if (!(surface->pending_state.pending & PendingBuffer
&& surface->pending_state.buffer))
wl_resource_post_error (synchronization->resource,
NoBuffer, "no buffer attached"

11
run.c
View file

@ -203,10 +203,7 @@ RunStep (void)
struct pollfd *fds;
PollFd **pollfds, *item, *last;
XFlush (compositor.display);
wl_display_flush_clients (compositor.wl_display);
fds = alloca (sizeof fds * (num_poll_fd + 2));
fds = alloca (sizeof *fds * (num_poll_fd + 2));
/* This is used as an optimization to not have to loop over the
entire descriptor list twice. */
@ -220,6 +217,12 @@ RunStep (void)
/* Drain complete selection transfers. */
FinishTransfers ();
/* FinishTransfers can potentially send events to Wayland clients
and make X requests. Flush after it is called. */
XFlush (compositor.display);
wl_display_flush_clients (compositor.wl_display);
/* Obtain the connections. */
x_connection = ConnectionNumber (compositor.display);
wl_connection = wl_event_loop_get_fd (compositor.wl_event_loop);

2
seat.c
View file

@ -2018,7 +2018,7 @@ CancelResizeOperation (Seat *seat, Time time, Subcompositor *subcompositor,
/* Ungrab the pointer. */
XIUngrabDevice (compositor.display, seat->master_pointer,
xev->time);
time);
if (!subcompositor)
return;

4
shm.c
View file

@ -88,8 +88,6 @@ DereferencePool (Pool *pool)
/* Cancel the busfault trap. */
if (pool->data != (void *) -1
/* If the pool is of size 0, no busfault was installed. */
&& pool->size
/* If reading from the pool cannot possibly cause SIGBUS, then
no bus fault trap was installed. */
&& !(pool->flags & PoolCannotSigbus))
@ -486,7 +484,7 @@ CreatePool (struct wl_client *client, struct wl_resource *resource,
/* Begin trapping SIGBUS from this pool. The client may truncate
the file without telling us, in which case accessing its contents
will cause crashes. */
if (!(pool->flags & PoolCannotSigbus) && pool->size)
if (!(pool->flags & PoolCannotSigbus))
XLRecordBusfault (pool->data, pool->size);
pool->fd = fd;

View file

@ -737,7 +737,6 @@ Setup (Surface *surface, Role *role)
ViewInsert (parent_view, surface->view);
/* Now move the subsurface to its initial location (0, 0) */
if (subsurface->parent)
MoveFractional (subsurface);
/* Now add the subsurface to the parent's list of subsurfaces. */

View file

@ -485,7 +485,7 @@ SetCursorRectangle (struct wl_client *client, struct wl_resource *resource,
if ((input->current_state.pending & PendingCursorRectangle
/* PendingEnabled will clear the current state's cursor
rectangle. */
&& !input->pending_state.pending & PendingEnabled)
&& !(input->pending_state.pending & PendingEnabled))
&& x == input->current_state.cursor_x
&& y == input->current_state.cursor_y
&& width == input->current_state.cursor_width
@ -1956,8 +1956,8 @@ FindTextSections (const char *string, size_t string_size,
while (factor)
{
found = memrchr (string, '\n', found - string);
DebugPrint ("LineStart processing found %p %zd", found,
found - string);
DebugPrint ("LineStart processing found %p %td", found,
found ? found - string : 0);
if (!found)
{
@ -2126,7 +2126,7 @@ EncodeIMString (const char *input, size_t input_size, int *chars)
{
rc = iconv (cd, &inbuf, &input_size, &outptr,
&outbytesleft);
DebugPrint ("iconv gave: %tu", rc);
DebugPrint ("iconv gave: %zu", rc);
if (rc == (size_t) -1)
{
@ -2144,7 +2144,7 @@ EncodeIMString (const char *input, size_t input_size, int *chars)
outsize += BUFSIZ;
outbytesleft += BUFSIZ;
DebugPrint ("expanding outsize to %tu, outbytesleft now %tu",
DebugPrint ("expanding outsize to %zu, outbytesleft now %zu",
outsize, outbytesleft);
}
else
@ -2167,7 +2167,7 @@ EncodeIMString (const char *input, size_t input_size, int *chars)
}
/* The conversion finished. */
DebugPrint ("conversion finished, size_out %tu",
DebugPrint ("conversion finished, size_out %zu",
outsize - outbytesleft);
/* Now, count the number of multibyte characters. */
@ -2624,7 +2624,7 @@ CheckStyles (XIM xim)
/* Otherwise, find the best style in our order of preference. */
for (i = 0; xim_style_order[i] != XimStyleNone; ++i)
{
DebugPrint ("considering style: %u", xim_style_order[i]);
DebugPrint ("considering style: %d", (int) xim_style_order[i]);
switch (xim_style_order[i])
{
@ -2945,7 +2945,7 @@ ConvertString (char *buffer, size_t nbytes, size_t *size_out)
outsize = BUFSIZ;
outbytesleft = outsize;
DebugPrint ("converting string of size %tu", nbytes);
DebugPrint ("converting string of size %zu", nbytes);
/* Reset the cd state. */
iconv (current_cd, NULL, NULL, &outptr, &outbytesleft);
@ -2956,7 +2956,7 @@ ConvertString (char *buffer, size_t nbytes, size_t *size_out)
rc = iconv (current_cd, &buffer, &nbytes,
&outptr, &outbytesleft);
DebugPrint ("iconv gave: %tu", rc);
DebugPrint ("iconv gave: %zu", rc);
if (rc == (size_t) -1)
{
@ -2974,7 +2974,7 @@ ConvertString (char *buffer, size_t nbytes, size_t *size_out)
outsize += BUFSIZ;
outbytesleft += BUFSIZ;
DebugPrint ("expanding outsize to %tu, outbytesleft now %tu",
DebugPrint ("expanding outsize to %zu, outbytesleft now %zu",
outsize, outbytesleft);
}
else
@ -2983,7 +2983,7 @@ ConvertString (char *buffer, size_t nbytes, size_t *size_out)
}
finish:
DebugPrint ("conversion finished, size_out %tu",
DebugPrint ("conversion finished, size_out %zu",
outsize - outbytesleft);
/* Return outbuf and the number of bytes put in it. */
@ -3032,7 +3032,7 @@ PreeditString (TextInput *input, const char *buffer,
end += skip;
}
DebugPrint ("end-start (%p-%p): %zd", end, start,
DebugPrint ("end-start (%p-%p): %td", end, start,
end - start);
/* Now, start to end contain a UTF-8 sequence less than 4000
@ -3101,7 +3101,7 @@ CommitString (TextInput *input, const char *buffer,
end += skip;
}
DebugPrint ("end-start (%p-%p): %zd", end, start,
DebugPrint ("end-start (%p-%p): %td", end, start,
end - start);
/* Now, start to end contain a UTF-8 sequence less than 4000

View file

@ -1147,14 +1147,14 @@ HandleSelectionNotify (XFixesSelectionNotifyEvent *event)
if (event->owner != None
&& event->selection == CLIPBOARD)
NoticeClipboardChanged (event->timestamp);
NoticeClipboardChanged (event->selection_timestamp);
else if (event->selection == CLIPBOARD)
NoticeClipboardCleared (event->timestamp);
NoticeClipboardCleared (event->selection_timestamp);
else if (event->owner != None
&& event->selection == XA_PRIMARY)
NoticePrimaryChanged (event->timestamp);
NoticePrimaryChanged (event->selection_timestamp);
else if (event->selection == XA_PRIMARY)
NoticePrimaryCleared (event->timestamp);
NoticePrimaryCleared (event->selection_timestamp);
}
Bool

View file

@ -279,10 +279,7 @@ MoveWindow (XdgPopup *popup)
int geometry_x, geometry_y, x, y;
Window window;
/* No parent was specified. */
if (!popup->parent)
return;
/* No parent was specified or the role is detached. */
if (!popup->role || !popup->parent)
return;
@ -416,10 +413,7 @@ InternalReposition (XdgPopup *popup)
int x, y, width, height;
FrameClock *clock;
/* No parent was specified. */
if (!popup->parent)
return;
/* No parent was specified or the role is detached. */
if (!popup->role || !popup->parent)
return;