Skip to content

Fixes for more cppcheck issues - #101

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

dalgaaf wants to merge 30 commits into
ceph:masterfrom
dalgaaf:wip-da-sca-style-4

Conversation

@dalgaaf

@dalgaaf dalgaaf commented Mar 12, 2013

Copy link
Copy Markdown
Contributor

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
…list

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

Signed-off-by: Danny Al-Gaaf <[email protected]>
Don't compare unsigned maxfilelen against less than zero.

Signed-off-by: Danny Al-Gaaf <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Comment thread src/mds/SessionMap.h

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 <[email protected]>
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 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 <[email protected]>

Co-authored-by: kupranay <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

Co-authored-by: kupranay <[email protected]>

* Rebase (ceph#88)

Signed-off-by: Parayya Vastrad <[email protected]>

* merge conflicts

* merge conflicts

* Review comments addressed

* Review comments addressed

Co-authored-by: root <[email protected]>
Co-authored-by: Diwakar92 <[email protected]>
Co-authored-by: kupranay <[email protected]>
Co-authored-by: Jeet Jain <[email protected]>
Co-authored-by: Saurabh Jain <[email protected]>
Co-authored-by: Parayya Vastrad <[email protected]>
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 <[email protected]>
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 <[email protected]>
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