Skip to content

Fixes for more cppcheck issues#101

Closed
dalgaaf wants to merge 30 commits intoceph:masterfrom
dalgaaf:wip-da-sca-style-4
Closed

Fixes for more cppcheck issues#101
dalgaaf wants to merge 30 commits intoceph:masterfrom
dalgaaf:wip-da-sca-style-4

Conversation

@dalgaaf
Copy link
Contributor

@dalgaaf dalgaaf commented Mar 12, 2013

These commits address issues like:

  • use static_cast instead of C-Style cast
  • remove unused variables
  • perform initialization of variables in initialization list of constructor
  • use %u to format unsigned in snprintf()
  • remove never executed statements after return
  • reduce scope of some variables
  • catch exception by reference
  • return 'const string' instead of 'const char *' to avoid potentially dangerous usage of std::string::c_str on return from a function
  • prefer prefix ++/--operator for non-primitive types

dalgaaf added 30 commits March 12, 2013 10:01
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
…list

Perform initialization of IntentLogNameFilter:prefix in initialization list
instead of constructor body.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Don't compare unsigned maxfilelen against less than zero.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Use ctx->ret() instead of bl.length() as return value. The length of
bl can be checked by the caller, return status instead as already done
in the other functions.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Return a string instead of 'char *' to avoid usage of std::string:c_str()
to return a 'char *' from get_state_name() in mon/Monitor.h.

Related warning from cppcheck:
 [src/mon/Monitor.h:172]: (error) Dangerous usage of c_str(). The value
 returned by c_str() is invalid after this call.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Prefer prefix ++operator for non-primitive types like iterators for
performance reasons. Prefix ++/-- operators avoid creating a temporary
copy.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these methods are marginally more efficient if they stay as const char *. Returning a const string is implicitly constructing a string object in memory, vs just returning a pointer to const text. In most cases the caller doesn't need the std::string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to return a string instead of char* due to usage of std::string::c_str() to return from get_state_name() in Monitor.h.

The problem with c_str() is that the result gets (may) invalid after the related string object gets destroyed or out of scope (which should be true on return). So you may get garbage in this case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. Yeah, that function should definitely be changed. The others that are just switches returning literal strings should stay const char *, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay ... I will submit another pull request to fix only the issue in Monitor.h

@liewegas
Copy link
Member

Everything looks good, except for the fsx and get_state_name() patches. Care to resubmit with those ones dropped?

@liewegas liewegas closed this Mar 12, 2013
liewegas added a commit that referenced this pull request Mar 12, 2013
Fixes for more cppcheck issues (v2 of #101)

Reviewed-by: Sage Weil <sage@inktank.com>
liewegas pushed a commit that referenced this pull request Dec 14, 2016
ricardoasmarques pushed a commit to ricardoasmarques/ceph that referenced this pull request Feb 16, 2018
…v2-rename-block_pool_to-rbd

mgr/dashboard_v2: Renamed `block_pool` controller to `rbd`
andriytk pushed a commit to andriytk/cortx-rgw that referenced this pull request Mar 3, 2022
* Fix for CORTX-28869:Unable to create IAM user with email

* Enable create user for same UID under different Tenant with motr as backend. (ceph#90)

Signed-off-by: Diwakar92 <diwakar.kumar@seagate.com>

Co-authored-by: kupranay <66459168+kupranay@users.noreply.github.com>

* rgw_sal_motr: [CORTX-28055] Support custom & multiple access/secret keys (ceph#93)

* rgw_sal_motr: [CORTX-28055] Support custom & multiple access/secret keys

Added support for multple key creation for a user which can be either custom or auto generated.

Signed-off-by: Jeet Jain <jeet.jain@seagate.com>

* rgw_sal_motr: [EOS-27516] Handling object overwrite during put-object (ceph#89)

* rgw_sal_motr: [EOS-27516] handling object overwrite

Deleting existing object data if same object is uploaded again to avoid object leak.

Signed-off-by: saurabh jain <saurabh.jain2@seagate.com>

* rgw_sal_motr: [EOS-27516] Handle parallel upload

During parallel object upload, there are chances of object leak, which can be handled by making use of GC. Since GC is not being use for motr as of now, adding a TODO for the same.

Signed-off-by: saurabh jain <saurabh.jain@seagate.com>

Co-authored-by: kupranay <66459168+kupranay@users.noreply.github.com>

* Rebase (ceph#88)

Signed-off-by: Parayya Vastrad <parayya.vastrad@seagate.com>

* merge conflicts

* merge conflicts

* Review comments addressed

* Review comments addressed

Co-authored-by: root <root@ssc-vm-g4-rhev4-0716.colo.seagate.com>
Co-authored-by: Diwakar92 <96409310+Diwakar92@users.noreply.github.com>
Co-authored-by: kupranay <66459168+kupranay@users.noreply.github.com>
Co-authored-by: Jeet Jain <jeet.jain@seagate.com>
Co-authored-by: Saurabh Jain <91066893+sjain09@users.noreply.github.com>
Co-authored-by: Parayya Vastrad <56255712+vastradparayya@users.noreply.github.com>
andriytk pushed a commit to andriytk/cortx-rgw that referenced this pull request Mar 17, 2022
* Fix for CORTX-28869:Unable to create IAM user with email

* Enable create user for same UID under different Tenant with motr as backend. (ceph#90)

Signed-off-by: Diwakar92 <diwakar.kumar@seagate.com>

Co-authored-by: kupranay <66459168+kupranay@users.noreply.github.com>

* rgw_sal_motr: [CORTX-28055] Support custom & multiple access/secret keys (ceph#93)

* rgw_sal_motr: [CORTX-28055] Support custom & multiple access/secret keys

Added support for multple key creation for a user which can be either custom or auto generated.

Signed-off-by: Jeet Jain <jeet.jain@seagate.com>

* rgw_sal_motr: [EOS-27516] Handling object overwrite during put-object (ceph#89)

* rgw_sal_motr: [EOS-27516] handling object overwrite

Deleting existing object data if same object is uploaded again to avoid object leak.

Signed-off-by: saurabh jain <saurabh.jain2@seagate.com>

* rgw_sal_motr: [EOS-27516] Handle parallel upload

During parallel object upload, there are chances of object leak, which can be handled by making use of GC. Since GC is not being use for motr as of now, adding a TODO for the same.

Signed-off-by: saurabh jain <saurabh.jain@seagate.com>

Co-authored-by: kupranay <66459168+kupranay@users.noreply.github.com>

* Rebase (ceph#88)

Signed-off-by: Parayya Vastrad <parayya.vastrad@seagate.com>

* merge conflicts

* merge conflicts

* Review comments addressed

* Review comments addressed

Co-authored-by: root <root@ssc-vm-g4-rhev4-0716.colo.seagate.com>
Co-authored-by: Diwakar92 <96409310+Diwakar92@users.noreply.github.com>
Co-authored-by: kupranay <66459168+kupranay@users.noreply.github.com>
Co-authored-by: Jeet Jain <jeet.jain@seagate.com>
Co-authored-by: Saurabh Jain <91066893+sjain09@users.noreply.github.com>
Co-authored-by: Parayya Vastrad <56255712+vastradparayya@users.noreply.github.com>
andriytk pushed a commit to andriytk/cortx-rgw that referenced this pull request Apr 1, 2022
User email index is not present.
Created user index and add user email entry in the email index in it.

Signed-off-by: Sanal Kaarthikeyan <sanal.kaarthikeyan@seagate.com>
galsalomon66 referenced this pull request in galsalomon66/ceph Sep 17, 2022
Support not between operator
expression [NOT] between expression AND expression

Signed-off-by: Albin Antony <aantony@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants