Testing removal of ifdef or configure checks: Difference between revisions

From SambaWiki
(show hints on using it)
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
=#ifdef removal is risky=
=#ifdef removal is risky=


Large-scale removal of "unused" ifdef is an important, but risky task.
Large-scale removal of "unused" ifdef or the configure checks that produce #defines is an important, but risky task.


It is difficult (and time consuming) to prove that the code is unused and that there is no change to the compiled output.
It is difficult (and time consuming) to prove that the code is unused and that there is no change to the compiled output.
Line 7: Line 7:
==A script to help==
==A script to help==


[[This script wraps gcc -E|File:Gcc-E.py.txt]] to attempt to solve this dilemma, so as to provide a result that can be reasoned with via tools like [https://www.samba.org/ftp/paulus/ dirdiff]
[[File:Gcc-E.py.txt]] is a Python script that wraps gcc -E to attempt to solve this dilemma, so as to provide a result that can be reasoned with via tools like [https://www.samba.org/ftp/paulus/ dirdiff]

===Getting the results===

git checkout origin/master
git clean -x -f -d
CC="gcc -E" ./configure.developer && make -j
mv bin /tmp/master-bin
git checkout newbranch
git clean -x -f -d
CC="gcc -E" ./configure.developer && make -j

===Reading the results===
dirdiff /tmp/master-bin bin
or
diff -ur --ignore-matching-lines="^#" /tmp/master-bin/ bin> /tmp/diff

Revision as of 02:30, 27 April 2019

#ifdef removal is risky

Large-scale removal of "unused" ifdef or the configure checks that produce #defines is an important, but risky task.

It is difficult (and time consuming) to prove that the code is unused and that there is no change to the compiled output.

A script to help

File:Gcc-E.py.txt is a Python script that wraps gcc -E to attempt to solve this dilemma, so as to provide a result that can be reasoned with via tools like dirdiff

Getting the results

git checkout origin/master
git clean -x -f -d
CC="gcc -E" ./configure.developer && make -j
mv bin /tmp/master-bin

git checkout newbranch
git clean -x -f -d
CC="gcc -E" ./configure.developer && make -j

Reading the results

dirdiff /tmp/master-bin bin

or

diff -ur --ignore-matching-lines="^#" /tmp/master-bin/ bin> /tmp/diff