[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Some variables show redefined abnormally.
From: |
Sergey Poznyakoff |
Subject: |
Re: Some variables show redefined abnormally. |
Date: |
Tue, 30 Mar 2021 09:36:03 +0300 |
Hi,
> I'm trying to analyse the source code of isc dhcp with cflow. Here is the
> download link:
> https://downloads.isc.org/isc/dhcp/4.4.2/dhcp-4.4.2.tar.gz
>
> When I used cflow analyse the client mode, I got many logs, here is some
> passages:
There are two main problems in your approach. I'll describe them briefly
first, and then will elaborate on the solution.
* Problems
First of all, it is not recommended to merge together sources from
different binaries and or libraries, like you do:
> cflow -m main \
> ./client/*.c \
> ./common/*.c \
> ./dhcpctl/*.c \
> ./keama/*.c \
> ./omapip/*.c \
> ./relay/*.c \
> ./server/*.c \
Cflow is designed to produce graph for a single binary or library upon
each invocation. So, instead of this, you should run cflow in each
subdirectory separately.
Secondly, the cflow.rc file you use is not sufficient. You can inspect
the default rc file supplied in the cflow tarball for more info.
Besides, dhcp code is a mixture of old K&R style and new ANSI style
code. Cflow versions up to 1.6 contained a bug that produced spurious
redefinition warnings on the code like:
unsigned f (a,l)
unsigned a;
unsigned l;
{
}
To fix this, please apply the following patch:
http://git.savannah.gnu.org/cgit/cflow.git/patch/?id=99179c774509f800966341743fb8c53517b79806
* Solution
For the complex multi-directory projects, I recommend to use the
attached makefile (flowgraph.mk). Copy it to the dhcp-4.4.2 directory.
Then, from that directory, run
make -f flowgraph.mk flowgraph
This will produce cflow charts in each subdirectory of the project:
client/dhclient.cflow
dhcpctl/omshell.cflow
relay/dhcrelay.cflow
server/dhcpd.cflow
See the file's header for more info.
Hope that helps.
Regards,
Sergey
# SYNOPSIS
# make -f flowgraph.mk flowgraph
# make -f flowgraph.mk flowclean
#
# DESCRIPTION
# Creates or cleans up flowgraphs in each source directory in the project.
# Flowgraphs are created using GNU cflow.
#
# PREREQUISITES
# 1. The project must be using GNU autotools.
# 2. It must be properly configured.
# 3. This file must be located in the top-level source directory of
# the project.
#
# COPYRIGHT
# Copyright (C) 2018-2021 Sergey Poznyakoff
# License GPLv3+: GNU GPL version 3 or later
# <http://gnu.org/licenses/gpl.html>
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law.
ifneq (,$(wildcard Makefile))
include Makefile
else
$(warning This file must be located in the top-level source directory of the
project,)
$(warning and the project itself must be properly configured for building.)
$(warning See the header comment of this file for more info.)
$(error Please, fix this and retry)
endif
CFLOW_FLAGS=-i^s --brief --all\
--define '__attribute__\(c\)'\
--define '__typeof\(c\)=int' \
--symbol __inline:=inline\
--symbol __inline__:=inline\
--symbol __const__:=const\
--symbol __const:=const\
--symbol __restrict:=restrict\
--symbol __extension__:qualifier\
--symbol __asm__:wrapper\
--symbol __nonnull:wrapper\
--symbol __wur:wrapper
FLOWCLEAN_FILES=
define flowgraph_tmpl
$(if $($(2)_OBJECTS),
FLOWCLEAN_FILES += $(1).cflow
$(2)_CFLOW_INPUT=$$(filter %.c, $$($(2)_SOURCES))
$(1).cflow: $$($(2)_CFLOW_INPUT) Makefile
$$(AM_V_GEN)cflow -o$$@ $$(CFLOW_FLAGS) $$(DEFS) \
$$(DEFAULT_INCLUDES) $$(INCLUDES) $$(AM_CPPFLAGS) \
$$(CPPFLAGS) \
$$($(2)_CFLOW_INPUT)
,
$(1).cflow:;
)
endef
all: flowgraph
$(foreach prog,$(bin_PROGRAMS) $(sbin_PROGRAMS),\
$(eval $(call flowgraph_tmpl,$(prog),$(subst -,_,$(prog)),$(OBJEXT))))
$(foreach prog,$(lib_LTLIBRARIES),\
$(eval $(call flowgraph_tmpl,$(prog),$(subst .,_,$(prog)),lo)))
flowgraph-local: $(foreach prog,$(bin_PROGRAMS) $(sbin_PROGRAMS)
$(lib_LTLIBRARIES),$(prog).cflow)
flowclean-local:
-@test -n "$(FLOWCLEAN_FILES)" && rm -f $(FLOWCLEAN_FILES)
##
MAINT_MK = $(abspath $(firstword $(MAKEFILE_LIST)))
MAINT_INC = $(dir $(MAINT_MK))
LOCAL_MK = $(notdir $(firstword $(MAKEFILE_LIST)))
flowgraph flowclean:
@$(MAKE) -f $(MAINT_MK) $@-recursive
flowgraph-recursive flowclean-recursive:
failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
target=`echo $@ | sed s/-recursive/-local/`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
continue; \
fi; \
if test -f $$subdir/$(LOCAL_MK); then \
makefile='$(LOCAL_MK)'; \
else \
makefile="$(MAINT_MK)"; \
fi; \
$(MAKE) -C $$subdir -f $$makefile -I $(MAINT_INC) $$target \
|| eval $$failcom; \
done; \
test -z "$$fail"