Skip to content

Remove unnecessary null pointer checks before delete/free#56

Open
lumir-sliva wants to merge 6 commits intocern-eos:masterfrom
lumir-sliva:fix/remove-unnecessary-null-checks
Open

Remove unnecessary null pointer checks before delete/free#56
lumir-sliva wants to merge 6 commits intocern-eos:masterfrom
lumir-sliva:fix/remove-unnecessary-null-checks

Conversation

@lumir-sliva
Copy link
Copy Markdown

Summary

Remove redundant null pointer checks before delete and free() calls in three locations identified in #53.

In C++, delete nullptr is guaranteed to be a no-op by the standard (ISO C++ FAQ). Similarly, free(NULL) is defined as a no-op by the C standard (C11 §7.22.3.3).

Changes

  • fst/xrdcl_plugins/RainFile.cc — Removed if (pFile) and if (pRainFile) guards in the RainFile destructor
  • fst/http/s3/S3Handler.cc — Removed if (mFile) guard in HandleRequest; the delete and subsequent null assignment are preserved
  • auth_plugin/ProtoUtils.cc — Removed if (obj->reqid) and if (obj->notify != nullptr) guards before free() in DeleteXrdSfsPrep

Fixes #53

esindril and others added 6 commits March 20, 2026 14:48
…t is not

the current when we are trying to fix. Otherwise, files that have checksum
errors and that never update the diskchecksum field, are never recovered.
delete on a null pointer is guaranteed to be a no-op by the C++
standard, and free(NULL) is a no-op per C11 §7.22.3.3. The redundant
guards add visual noise without providing any safety benefit.

Github-Issue:cern-eos#53
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.

Remove unnecessary null pointer checks

3 participants