Bug 152299 - Remove unused define(s) from C/C++ files
Summary: Remove unused define(s) from C/C++ files
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.5.0
Keywords: difficultyBeginner, easyHack
Depends on:
Blocks: Dev-related
  Show dependency treegraph
 
Reported: 2022-11-29 14:50 UTC by Hossein
Modified: 2023-04-11 21:01 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hossein 2022-11-29 14:50:49 UTC
There are many macros and symbolic constants defined in LibreOffice C/C++ source code. Throughout the time, some of these defines are no longer in use, so it is good to remove them to clean up the source code.

Read more about macros here:
https://en.wikipedia.org/wiki/C_preprocessor#Macro_definition_and_expansion

You can check to see if a define is used by searching for it inside the code. You can use 'git grep' to do a search inside the code.

As an example, look into the below commit. Caolán has mentioned the exact commit that starting with that, the define is no longer used. Such a comment in the description is nice to have.

commit 98700f59bb72a2c67b48656eacbac7ebdd4ead7b
Author: Caolán McNamara <caolanm@redhat.com>
Date:   Mon Nov 28 12:42:38 2022 +0000

    unused ERR_SWG_OLD_GLOSSARY define
    
    since
    
    commit cae829e9c1394851fc88829d5197460929c2792a

Notes:
The symbolic constants can be consumed/defined in the Makefile(s), so you should be careful. It is suggested that you limit your changes only to C/C++ sources and the header files. This is an example of a revert for an incorrect removal:

vcl: restore lost spinner images 214438f1dcce52043c27c39e529cf60ff96c98cf

The above defines where consumed in a Makefile, and as they were created on the fly, a search didn't show them.
Comment 1 Miklos Vajna 2022-12-06 14:15:39 UTC
Limiting this to C/C++ files look sane to me. And perhaps also exclude URE headers (see <https://github.com/libreoffice/core/blob/645f8038df617275e65e05bba0b165a1c52ce59b/compilerplugins/clang/plugin.cxx#L447-L464>) as well.
Comment 2 Commit Notification 2022-12-08 22:39:24 UTC
Bogdan B committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0569a84c16e6ee6ed6f4fb52c23ed6dfe4225cdf

tdf#152299 - Remove unused define(s) from C/C++ files

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.