From 0a793bb887950644d9fb1ff4435bb0b527539e6e Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Thu, 8 Jan 2026 10:32:29 +0100 Subject: [PATCH] [clang,warnings] fix Wjump-misses-init --- client/X11/xf_cliprdr.c | 164 +++++++++++++++++++++------------------- 1 file changed, 88 insertions(+), 76 deletions(-) diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 041b399d0..88c3ee798 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -712,54 +712,57 @@ static CLIPRDR_FORMAT* xf_cliprdr_get_formats_from_targets(xfClipboard* clipboar } } - BOOL isImage = FALSE; - BOOL hasHtml = FALSE; - const uint32_t htmlFormatId = ClipboardRegisterFormat(clipboard->system, type_HtmlFormat); - for (unsigned long i = 0; i < proplength; i++) { - Atom tatom = ((Atom*)data)[i]; - const xfCliprdrFormat* format = xf_cliprdr_get_client_format_by_atom(clipboard, tatom); + BOOL isImage = FALSE; + BOOL hasHtml = FALSE; + const uint32_t htmlFormatId = ClipboardRegisterFormat(clipboard->system, type_HtmlFormat); + for (unsigned long i = 0; i < proplength; i++) + { + Atom tatom = ((Atom*)data)[i]; + const xfCliprdrFormat* format = xf_cliprdr_get_client_format_by_atom(clipboard, tatom); - if (xf_cliprdr_should_add_format(formats, *numFormats, format)) + if (xf_cliprdr_should_add_format(formats, *numFormats, format)) + { + CLIPRDR_FORMAT* cformat = &formats[*numFormats]; + cformat->formatId = format->formatToRequest; + + /* We do not want to double register a format, so check if HTML was already + * registered. + */ + if (cformat->formatId == htmlFormatId) + hasHtml = TRUE; + + /* These are standard image types that will always be registered regardless of + * actual image format. */ + if (cformat->formatId == CF_TIFF) + isImage = TRUE; + else if (cformat->formatId == CF_DIB) + isImage = TRUE; + else if (cformat->formatId == CF_DIBV5) + isImage = TRUE; + + if (format->formatName) + { + cformat->formatName = _strdup(format->formatName); + WINPR_ASSERT(cformat->formatName); + } + else + cformat->formatName = NULL; + + *numFormats += 1; + } + } + + clipboard->isImageContent = isImage; + if (isImage && !hasHtml) { CLIPRDR_FORMAT* cformat = &formats[*numFormats]; - cformat->formatId = format->formatToRequest; - - /* We do not want to double register a format, so check if HTML was already registered. - */ - if (cformat->formatId == htmlFormatId) - hasHtml = TRUE; - - /* These are standard image types that will always be registered regardless of actual - * image format. */ - if (cformat->formatId == CF_TIFF) - isImage = TRUE; - else if (cformat->formatId == CF_DIB) - isImage = TRUE; - else if (cformat->formatId == CF_DIBV5) - isImage = TRUE; - - if (format->formatName) - { - cformat->formatName = _strdup(format->formatName); - WINPR_ASSERT(cformat->formatName); - } - else - cformat->formatName = NULL; + cformat->formatId = htmlFormatId; + cformat->formatName = _strdup(type_HtmlFormat); *numFormats += 1; } } - - clipboard->isImageContent = isImage; - if (isImage && !hasHtml) - { - CLIPRDR_FORMAT* cformat = &formats[*numFormats]; - cformat->formatId = htmlFormatId; - cformat->formatName = _strdup(type_HtmlFormat); - - *numFormats += 1; - } out: if (data) @@ -2545,50 +2548,59 @@ xfClipboard* xf_clipboard_new(xfContext* xfc, BOOL relieveFilenameRestriction) * registration). However, they are definitely not supported if there are no registered * formats. In this case we should not list file formats in TARGETS. */ - const UINT32 fgid = ClipboardGetFormatId(clipboard->system, type_FileGroupDescriptorW); - const UINT32 uid = ClipboardGetFormatId(clipboard->system, mime_uri_list); - if (uid) { - cliprdr_file_context_set_locally_available(clipboard->file, TRUE); - clientFormat->atom = Logging_XInternAtom(xfc->log, xfc->display, mime_uri_list, False); - clientFormat->localFormat = uid; - clientFormat->formatToRequest = fgid; - clientFormat->formatName = _strdup(type_FileGroupDescriptorW); + const UINT32 fgid = ClipboardGetFormatId(clipboard->system, type_FileGroupDescriptorW); + { + const UINT32 uid = ClipboardGetFormatId(clipboard->system, mime_uri_list); + if (uid) + { + cliprdr_file_context_set_locally_available(clipboard->file, TRUE); + clientFormat->atom = + Logging_XInternAtom(xfc->log, xfc->display, mime_uri_list, False); + clientFormat->localFormat = uid; + clientFormat->formatToRequest = fgid; + clientFormat->formatName = _strdup(type_FileGroupDescriptorW); - if (!clientFormat->formatName) - goto fail; + if (!clientFormat->formatName) + goto fail; - clientFormat = &clipboard->clientFormats[n++]; - } + clientFormat = &clipboard->clientFormats[n++]; + } + } - const UINT32 gid = ClipboardGetFormatId(clipboard->system, mime_gnome_copied_files); - if (gid != 0) - { - cliprdr_file_context_set_locally_available(clipboard->file, TRUE); - clientFormat->atom = - Logging_XInternAtom(xfc->log, xfc->display, mime_gnome_copied_files, False); - clientFormat->localFormat = gid; - clientFormat->formatToRequest = fgid; - clientFormat->formatName = _strdup(type_FileGroupDescriptorW); + { + const UINT32 gid = ClipboardGetFormatId(clipboard->system, mime_gnome_copied_files); + if (gid != 0) + { + cliprdr_file_context_set_locally_available(clipboard->file, TRUE); + clientFormat->atom = + Logging_XInternAtom(xfc->log, xfc->display, mime_gnome_copied_files, False); + clientFormat->localFormat = gid; + clientFormat->formatToRequest = fgid; + clientFormat->formatName = _strdup(type_FileGroupDescriptorW); - if (!clientFormat->formatName) - goto fail; + if (!clientFormat->formatName) + goto fail; - clientFormat = &clipboard->clientFormats[n++]; - } + clientFormat = &clipboard->clientFormats[n++]; + } + } - const UINT32 mid = ClipboardGetFormatId(clipboard->system, mime_mate_copied_files); - if (mid != 0) - { - cliprdr_file_context_set_locally_available(clipboard->file, TRUE); - clientFormat->atom = - Logging_XInternAtom(xfc->log, xfc->display, mime_mate_copied_files, False); - clientFormat->localFormat = mid; - clientFormat->formatToRequest = fgid; - clientFormat->formatName = _strdup(type_FileGroupDescriptorW); + { + const UINT32 mid = ClipboardGetFormatId(clipboard->system, mime_mate_copied_files); + if (mid != 0) + { + cliprdr_file_context_set_locally_available(clipboard->file, TRUE); + clientFormat->atom = + Logging_XInternAtom(xfc->log, xfc->display, mime_mate_copied_files, False); + clientFormat->localFormat = mid; + clientFormat->formatToRequest = fgid; + clientFormat->formatName = _strdup(type_FileGroupDescriptorW); - if (!clientFormat->formatName) - goto fail; + if (!clientFormat->formatName) + goto fail; + } + } } clipboard->numClientFormats = WINPR_ASSERTING_INT_CAST(uint32_t, n);