All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin ROBIN <dev@benjarobin.fr>
To: Yordan Karadzhov <y.karadz@gmail.com>
Cc: <linux-trace-devel@vger.kernel.org>, <dev@benjarobin.fr>
Subject: Re: [PATCH 04/34] kernelshark: Do not create a temporary container for looping over QMap
Date: Sun, 4 Feb 2024 19:59:08 +0100	[thread overview]
Message-ID: <gqbzlzqe3pss4opieve4c35xjgq7fgdgjh6iiq3zdm2ei5osnw@ac3adq75s3ez> (raw)
In-Reply-To: <bc2f74e7-6e1b-7f2e-40e0-b40c842a7bb4@gmail.com>

On Sun, Feb 04, 2024 at 08:34:39PM +0200, Yordan Karadzhov wrote:
> 
> 
> On 1/28/24 22:30, Benjamin ROBIN wrote:
> > On Sun, Jan 21, 2024 at 07:16:01PM +0200, Yordan Karadzhov wrote:
> > > 
> > > 
> > > On 1/14/24 19:16, Benjamin ROBIN wrote:
> > > > Use const_iterator instead. Fix container-anti-pattern Clazy warning
> > > > 
> > > > Signed-off-by: Benjamin ROBIN <dev@benjarobin.fr>
> > > > ---
> > > >    src/KsAdvFilteringDialog.cpp | 6 +++---
> > > >    1 file changed, 3 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/src/KsAdvFilteringDialog.cpp b/src/KsAdvFilteringDialog.cpp
> > > > index 4683c3d..247f912 100644
> > > > --- a/src/KsAdvFilteringDialog.cpp
> > > > +++ b/src/KsAdvFilteringDialog.cpp
> > > > @@ -276,8 +276,8 @@ void KsAdvFilteringDialog::_makeFilterTable()
> > > >    	headers << "Delete" << "Stream" << "Event" << " Id" << "Filter";
> > > >    	_table->init(headers, _filters.count());
> > > > -	for(auto f : _filters.keys()) {
> > > > -		QStringList thisFilter = _filters.value(f).split(":");
> > > > +	for (auto it = _filters.cbegin(), end = _filters.cend(); it != end; ++it) {
> > > 
> > > Do we need to use iterator here?
> > > Perhaps you can do something like:
> > > 
> > > for (const auto &[key, val] : _filters) {
> > 
> > Unfortunately, you cannot do that, as far as I know (this not compile).
> > C++ range-based for loop is using iterator behind the scene. See [1].
> > And there is still the problem of range-loop-detach (see patch 0005).
> > Using const iterator is the most explicit and safe way to iterate over a
> > container in Qt, so why not using it?
> 
> I see your point. I am applying this patch together with all v2 patches you
> sent.
> 
> Are you considering sending new version of the "[31/34] Fix comparison of
> integers of different signs warnings"?

I did not have time last weekend, nor this weekend to take a deep loop into it. 
Fixing types is not that easy:
 - I need a better understanding of the code base, otherwise I will break stuff.
 - I don't know if there are other projects that rely on these lib headers
   files. Is it possible to refactor every part of the project without breaking 
   something else?
 - My patch tried to fix at various places warnings using mainly cast, but there
   are so many other places where the types are wrong (or at least not the optimal
   one).
 - This task is not that small. It requires a bit more time.

So, in summary, this patch is currently on hold. I may work on it later this 
year... Sorry about that.

Thanks,
Benjamin

> > 
> > [1] https://en.cppreference.com/w/cpp/language/range-for
> > > Thanks!
> > > Y.
> > > 
> > > > +		QStringList thisFilter = it.value().split(":");
> > > >    		i1 = new QTableWidgetItem(thisFilter[0]);
> > > >    		_table->setItem(count, 1, i1);
> > > > @@ -285,7 +285,7 @@ void KsAdvFilteringDialog::_makeFilterTable()
> > > >    		i1 = new QTableWidgetItem(thisFilter[1]);
> > > >    		_table->setItem(count, 2, i1);
> > > > -		i2 = new QTableWidgetItem(tr("%1").arg(f));
> > > > +		i2 = new QTableWidgetItem(tr("%1").arg(it.key()));
> > > >    		_table->setItem(count, 3, i2);
> > > >    		i3 = new QTableWidgetItem(thisFilter[2]);

  reply	other threads:[~2024-02-04 19:17 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-14 17:16 [PATCH 00/34] Fix kernelshark issues introduced by the migration to Qt6 Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 01/34] kernelshark: Fix modelReset() signaling, rename update to updateGeom Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 02/34] kernelshark: Add .gitignore Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 03/34] kernelshark: Remove function param when not used, whenever possible Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 04/34] kernelshark: Do not create a temporary container for looping over QMap Benjamin ROBIN
2024-01-21 17:16   ` Yordan Karadzhov
2024-01-28 21:30     ` Benjamin ROBIN
2024-02-04 18:34       ` Yordan Karadzhov
2024-02-04 18:59         ` Benjamin ROBIN [this message]
2024-01-14 17:16 ` [PATCH 05/34] kernelshark: Prevent potential detach of QMap container Benjamin ROBIN
2024-01-21 17:17   ` Yordan Karadzhov
2024-01-28 19:38     ` [PATCH v2 " Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 06/34] kernelshark: Fix used after free of QByteArray raw data Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 07/34] kernelshark: Fix potential memory leak in KsGLWidget Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 08/34] kernelshark: Use lambda parameter instead of captured local variable Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 09/34] kernelshark: Keep overridden method protected instead of public Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 10/34] kernelshark: Use sliced() or first() instead of mid/right/left() Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 11/34] kernelshark: Prevent potential divide by zero in Shape::center() Benjamin ROBIN
2024-01-21 19:49   ` Yordan Karadzhov
2024-01-28 19:26     ` [PATCH v2 " Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 12/34] kernelshark: Fix potential access to uninitialized variable Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 13/34] kernelshark: Remove unused locals variables Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 14/34] kernelshark: Fix range-loop-reference Clazy warning Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 15/34] kernelshark: Fix moving a temp object prevents copy elision warning Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 16/34] kernelshark: Add receiver object to connect() call Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 17/34] kernelshark: Return by reference the list of header in KsModels Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 18/34] kernelshark: Fix detaching-temporary Clazy warning Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 19/34] kernelshark: Fix qfileinfo-exists " Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 20/34] kernelshark: Fix potential memory leaks in libkshark-configio Benjamin ROBIN
2024-01-21 18:41   ` Yordan Karadzhov
2024-01-28 19:25     ` [PATCH v2 " Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 21/34] kernelshark: Fix potential access to uninitialized variable Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 22/34] kernelshark: Fix potential double free of histo->map, histo->bin_count Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 23/34] kernelshark: Fix 'const' type qualifier on return type has no effect Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 24/34] kernelshark: Fix potential memory leaks in libkshark-tepdata Benjamin ROBIN
2024-01-21 18:50   ` Yordan Karadzhov
2024-01-28 19:24     ` [PATCH v2 " Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 25/34] kernelshark: Fix typo in comment of KsGLWidget::resizeGL() Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 26/34] kernelshark: Remove unused KsDataWidget::wipPtr() and broken function Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 27/34] kernelshark: In KsTimeOffsetDialog() constructor use parent param Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 28/34] kernelshark: Fixed loop counter incremented suspiciously twice Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 29/34] kernelshark: Fix tepdata_dump_entry() for event_id = KS_EVENT_OVERFLOW Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 30/34] kernelshark: Use static_cast instead of C cast in KsMainWindow Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 31/34] kernelshark: Fix comparison of integers of different signs warnings Benjamin ROBIN
2024-01-21 19:09   ` Yordan Karadzhov
2024-01-14 17:17 ` [PATCH 32/34] kernelshark: Fix KsTableView columns width, and KsTraceViewer size Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 33/34] kernelshark: Allow to reduce a bit more the graph height Benjamin ROBIN
2024-01-21 19:37   ` Yordan Karadzhov
2024-01-28 18:59     ` [PATCH v2 " Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 34/34] kernelshark: Cleanup of KsDualMarker methods Benjamin ROBIN
2024-01-21 17:08 ` [PATCH 00/34] Fix kernelshark issues introduced by the migration to Qt6 Yordan Karadzhov
2024-03-03  9:56   ` Benjamin ROBIN
2024-03-03 15:47     ` Yordan Karadzhov
2024-03-03 17:07       ` Sudip Mukherjee
2024-03-03 20:43         ` Sudip Mukherjee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=gqbzlzqe3pss4opieve4c35xjgq7fgdgjh6iiq3zdm2ei5osnw@ac3adq75s3ez \
    --to=dev@benjarobin.fr \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=y.karadz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.