From 222883d98f60a83af032bcb4e937cbe9d03fe599 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Thu, 23 Nov 2023 09:17:21 -0800 Subject: [PATCH] Avoid Clang -Wcomma warnings For the few cases that are not trivially avoidable, use a cast to void to silence the warning. --- samples/event/chessboard.cpp | 2 +- src/common/encconv.cpp | 5 ++++- src/common/fs_arc.cpp | 4 ++-- src/common/imagiff.cpp | 4 ++-- src/common/wxcrt.cpp | 5 ++++- src/generic/grid.cpp | 10 ++++++++-- src/generic/headerctrlg.cpp | 2 +- src/html/htmlcell.cpp | 3 ++- src/html/htmltag.cpp | 10 ++++++++-- src/html/m_image.cpp | 3 ++- src/html/winpars.cpp | 3 ++- src/osx/carbon/region.cpp | 4 ++-- src/osx/listbox_osx.cpp | 2 +- src/propgrid/editors.cpp | 2 +- src/qt/colour.cpp | 2 +- 15 files changed, 41 insertions(+), 20 deletions(-) diff --git a/samples/event/chessboard.cpp b/samples/event/chessboard.cpp index 49d4a67dd6..9ab996f6df 100644 --- a/samples/event/chessboard.cpp +++ b/samples/event/chessboard.cpp @@ -72,7 +72,7 @@ ChessBoard::ChessBoard(wxWindow* parent) return false; // not on a square } - file = FileLetters[colIdx], + file = FileLetters[colIdx]; // convert rowIdx (top to down 0 to 7) to rank (top to down 8 to 1) rank = static_cast(SquaresPerSide - rowIdx); diff --git a/src/common/encconv.cpp b/src/common/encconv.cpp index 75ec493b28..0514bf008c 100644 --- a/src/common/encconv.cpp +++ b/src/common/encconv.cpp @@ -87,7 +87,10 @@ static CharsetItem* BuildReverseTable(const wxUint16 *tbl) CharsetItem *rev = new CharsetItem[128]; for (int i = 0; i < 128; i++) - rev[i].c = wxUint8(128 + i), rev[i].u = tbl[i]; + { + rev[i].c = wxUint8(128 + i); + rev[i].u = tbl[i]; + } qsort(rev, 128, sizeof(CharsetItem), CompareCharsetItems); diff --git a/src/common/fs_arc.cpp b/src/common/fs_arc.cpp index 19b7c7dc65..4b2505b02a 100644 --- a/src/common/fs_arc.cpp +++ b/src/common/fs_arc.cpp @@ -438,9 +438,9 @@ wxString wxArchiveFSHandler::FindFirst(const wxString& spec, int flags) switch (flags) { case wxFILE: - m_AllowDirs = false, m_AllowFiles = true; break; + m_AllowDirs = false; m_AllowFiles = true; break; case wxDIR: - m_AllowDirs = true, m_AllowFiles = false; break; + m_AllowDirs = true; m_AllowFiles = false; break; default: m_AllowDirs = m_AllowFiles = true; break; } diff --git a/src/common/imagiff.cpp b/src/common/imagiff.cpp index 6254e89dce..e7e8df8a80 100644 --- a/src/common/imagiff.cpp +++ b/src/common/imagiff.cpp @@ -158,8 +158,8 @@ bool wxIFFDecoder::ConvertToImage(wxImage *image) const } } - pal[3 * transparent + 0] = 255, - pal[3 * transparent + 1] = 0, + pal[3 * transparent + 0] = 255; + pal[3 * transparent + 1] = 0; pal[3 * transparent + 2] = 255; image->SetMaskColour(255, 0, 255); diff --git a/src/common/wxcrt.cpp b/src/common/wxcrt.cpp index fc9ee02aee..c0511899a6 100644 --- a/src/common/wxcrt.cpp +++ b/src/common/wxcrt.cpp @@ -739,7 +739,10 @@ WXDLLIMPEXP_BASE int wxCRT_StrnicmpW(const wchar_t *s1, const wchar_t *s2, size_ { // initialize the variables just to suppress stupid gcc warning wchar_t c1 = 0, c2 = 0; - while (n && ((c1 = wxTolower(*s1)) == (c2 = wxTolower(*s2)) ) && c1) n--, s1++, s2++; + while (n && ((c1 = wxTolower(*s1)) == (c2 = wxTolower(*s2)) ) && c1) + { + n--; s1++; s2++; + } if (n) { if (c1 < c2) return -1; if (c1 > c2) return 1; diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 979a3a0cce..83123ca54f 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -4939,9 +4939,15 @@ void wxGrid::ProcessGridCellMouseEvent(wxMouseEvent& event, wxGridWindow *eventG DisableCellEditControl(); if ( event.LeftDown() ) - handled = (DoGridCellLeftDown(event, coords, pos), true); + { + DoGridCellLeftDown(event, coords, pos); + handled = true; + } else if ( event.LeftDClick() ) - handled = (DoGridCellLeftDClick(event, coords, pos), true); + { + DoGridCellLeftDClick(event, coords, pos); + handled = true; + } else if ( event.RightDown() ) handled = SendEvent(wxEVT_GRID_CELL_RIGHT_CLICK, coords, event) != Event_Unhandled; else if ( event.RightDClick() ) diff --git a/src/generic/headerctrlg.cpp b/src/generic/headerctrlg.cpp index 79a31a0eb2..d24a615f9f 100644 --- a/src/generic/headerctrlg.cpp +++ b/src/generic/headerctrlg.cpp @@ -652,7 +652,7 @@ void wxHeaderCtrl::OnMouse(wxMouseEvent& mevent) // find if the event is over a column at all bool onSeparator; const unsigned col = mevent.Leaving() - ? (onSeparator = false, COL_NONE) + ? ((void)(onSeparator = false), COL_NONE) : FindColumnAtPoint(xPhysical, &onSeparator); diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index e762d2aa3e..18ee7036ee 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -1588,7 +1588,8 @@ wxHtmlWidgetCell::wxHtmlWidgetCell(wxWindow *wnd, int w) int sx, sy; m_Wnd = wnd; m_Wnd->GetSize(&sx, &sy); - m_Width = sx, m_Height = sy; + m_Width = sx; + m_Height = sy; m_WidthFloat = w; } diff --git a/src/html/htmltag.cpp b/src/html/htmltag.cpp index cf2daf1381..1961f150e9 100644 --- a/src/html/htmltag.cpp +++ b/src/html/htmltag.cpp @@ -407,9 +407,15 @@ wxHtmlTag::wxHtmlTag(wxHtmlTag *parent, if (!IS_WHITE(c)) { if (c == wxT('"') || c == wxT('\'')) - quote = c, pvalue = wxGetEmptyString(); + { + quote = c; + pvalue.clear(); + } else - quote = 0, pvalue = c; + { + quote = 0; + pvalue = c; + } state = ST_VALUE; } break; diff --git a/src/html/m_image.cpp b/src/html/m_image.cpp index dd800f882f..cee2fdfc9d 100644 --- a/src/html/m_image.cpp +++ b/src/html/m_image.cpp @@ -589,7 +589,8 @@ void wxHtmlImageCell::Draw(wxDC& dc, int x, int y, dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.SetPen(*wxBLACK_PEN); dc.DrawRectangle(x + m_PosX, y + m_PosY, m_Width, m_Height); - x++, y++; + x++; + y++; } if ( m_bitmap && m_Width && m_Height ) { diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp index 39da7c1d59..07bc8ef592 100644 --- a/src/html/winpars.cpp +++ b/src/html/winpars.cpp @@ -342,7 +342,8 @@ void wxHtmlWinParser::AddText(const wxString& txt) const wxChar d = temp[templen++] = *i; if ((d == wxT('\n')) || (d == wxT('\r')) || (d == wxT(' ')) || (d == wxT('\t'))) { - ++i, ++x; + ++i; + ++x; while ( (i < end) && (*i == wxT('\n') || *i == wxT('\r') || *i == wxT(' ') || *i == wxT('\t')) ) diff --git a/src/osx/carbon/region.cpp b/src/osx/carbon/region.cpp index e947111039..a5a118c19e 100644 --- a/src/osx/carbon/region.cpp +++ b/src/osx/carbon/region.cpp @@ -581,12 +581,12 @@ miCreateETandAET(int count, const wxPoint * pts, EdgeTable *ET, EdgeTableEntry * */ if (PrevPt->y > CurrPt->y) { - bottom = PrevPt, top = CurrPt; + bottom = PrevPt; top = CurrPt; pETEs->ClockWise = 0; } else { - bottom = CurrPt, top = PrevPt; + bottom = CurrPt; top = PrevPt; pETEs->ClockWise = 1; } diff --git a/src/osx/listbox_osx.cpp b/src/osx/listbox_osx.cpp index 1cd8e36b34..a37ecff47c 100644 --- a/src/osx/listbox_osx.cpp +++ b/src/osx/listbox_osx.cpp @@ -376,7 +376,7 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items, { const wxString& item = items[i]; idx = IsSorted() ? m_strings.sorted->Add(item) - : (m_strings.unsorted->Insert(item, pos), pos++); + : ((void)m_strings.unsorted->Insert(item, pos), pos++); m_itemsClientData.Insert(nullptr, idx); AssignNewItemClientData(idx, clientData, i, type); diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index e5f014258e..0b434cb536 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -678,7 +678,7 @@ public: { #ifdef wxPG_TEXTCTRLXADJUST textCtrlXAdjust = wxPG_TEXTCTRLXADJUST - - (wxPG_XBEFOREWIDGET+wxPG_CONTROL_MARGIN+1) - 1, + (wxPG_XBEFOREWIDGET+wxPG_CONTROL_MARGIN+1) - 1; #endif wxOwnerDrawnComboBox::PositionTextCtrl( textCtrlXAdjust + wxPG_TEXTCTRLXADJUST3, diff --git a/src/qt/colour.cpp b/src/qt/colour.cpp index a8954c1bb2..cc4dc19968 100644 --- a/src/qt/colour.cpp +++ b/src/qt/colour.cpp @@ -56,6 +56,6 @@ void wxColour::Init() void wxColour::InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) { - m_red = r, m_green = g, m_blue = b, m_alpha = a; + m_red = r; m_green = g; m_blue = b; m_alpha = a; m_valid = true; }