Ticket #30993

gcc4.6以降でのコンパイルエラー対処

Open Date: 2013-03-19 11:53 Last Update: 2013-10-17 13:07

Reporter:
Owner:
Type:
Status:
Closed
MileStone:
(None)
Priority:
4
Severity:
5 - Medium
Resolution:
Fixed
File:
1

Details

Debian testing上のgcc4.6でv3.0.4-3をコンパイルしたところ、以下がコンパイルエラーとして検出されました。

1. 宣言、値の代入はされているものの、一度も参照されない変数

例:
protocol_module_ip.cpp: In member function 'virtual
l7vs::protocol_module_base::check_message_result
l7vs::protocol_module_ip::check_parameter(const
std::vector<std::basic_string<char> >&)':
protocol_module_ip.cpp:327:14: error: variable 'forward_checked' set but
not used [-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
make[4]: *** [protocol_module_ip.lo] エラー 1

2. コンストラクタをまるでclassのように書く書き方

例:
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../../.. -g -O2
-fno-strict-aliasing -Wall -Werror -fPIC -pthread -I../../include
-I../../logger -I../../parameter -DMAX_BUFFER_SIZE=4096 -g -O2 -MT
protocol_module_ip.lo -MD -MP -MF .deps/protocol_module_ip.Tpo -c
protocol_module_ip.cpp -fPIC -DPIC -o .libs/protocol_module_ip.o
protocol_module_sessionless.cpp: In member function 'virtual
l7vs::protocol_module_base::check_message_result
l7vs::protocol_module_sessionless::check_parameter(const
std::vector<std::basic_string<char> >&)':
protocol_module_sessionless.cpp:359:14: error: variable
'forward_checked' set but not used [-Werror=unused-but-set-variable]
In file included from protocol_module_ip.cpp:33:0:
protocol_module_ip.h: In member function 'unsigned int
l7vs::protocol_module_ip::l7vs_ip_service_calc_hash(const endpoint&)':
protocol_module_ip.h:97:25: error:
'boost::asio::ip::address_v4::address_v4' names the constructor, not the
type
protocol_module_ip.h:97:65: error: expected ';' before 'v4_address'
protocol_module_ip.h:97:127: error: statement cannot resolve address of
overloaded function
protocol_module_ip.h:98:32: error: 'v4_address' was not declared in this
scope
In file included from protocol_module_ip.cpp:33:0:
protocol_module_ip.h:96:65: error: unused variable 'v4_bytes'
[-Werror=unused-variable]
cc1plus: all warnings being treated as errors
make[4]: *** [protocol_module_sessionless.lo] エラー 1
make[4]: *** 未完了のジョブを待っています....
cc1plus: all warnings being treated as errors
make[4]: *** [protocol_module_ip.lo] エラー 1

全エラーを以下に貼っておきます。

protocol_module_ip.cpp: In member function 'virtual
l7vs::protocol_module_base::check_message_result
l7vs::protocol_module_ip::check_parameter(const
std::vector<std::basic_string<char> >&)':
protocol_module_ip.cpp:327:14: error: variable 'forward_checked' set but
not used [-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
make[4]: *** [protocol_module_ip.lo] エラー 1

libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../../.. -g -O2
-fno-strict-aliasing -Wall -Werror -fPIC -pthread -I../../include
-I../../logger -I../../parameter -DMAX_BUFFER_SIZE=4096 -g -O2 -MT
protocol_module_ip.lo -MD -MP -MF .deps/protocol_module_ip.Tpo -c
protocol_module_ip.cpp -fPIC -DPIC -o .libs/protocol_module_ip.o
protocol_module_sessionless.cpp: In member function 'virtual
l7vs::protocol_module_base::check_message_result
l7vs::protocol_module_sessionless::check_parameter(const
std::vector<std::basic_string<char> >&)':
protocol_module_sessionless.cpp:359:14: error: variable
'forward_checked' set but not used [-Werror=unused-but-set-variable]
In file included from protocol_module_ip.cpp:33:0:
protocol_module_ip.h: In member function 'unsigned int
l7vs::protocol_module_ip::l7vs_ip_service_calc_hash(const endpoint&)':
protocol_module_ip.h:97:25: error:
'boost::asio::ip::address_v4::address_v4' names the constructor, not the
type
protocol_module_ip.h:97:65: error: expected ';' before 'v4_address'
protocol_module_ip.h:97:127: error: statement cannot resolve address of
overloaded function
protocol_module_ip.h:98:32: error: 'v4_address' was not declared in this
scope
In file included from protocol_module_ip.cpp:33:0:
protocol_module_ip.h:96:65: error: unused variable 'v4_bytes'
[-Werror=unused-variable]
cc1plus: all warnings being treated as errors
make[4]: *** [protocol_module_sessionless.lo] エラー 1
make[4]: *** 未完了のジョブを待っています....
cc1plus: all warnings being treated as errors
make[4]: *** [protocol_module_ip.lo] エラー 1


l7vsadm.cpp: In member function ‘bool l7vs::l7vsadm::execute(int, char**)’:
l7vsadm.cpp:2960:17: error: variable ‘retsize’ set but not used
[-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
make[3]: *** [l7vsadm-l7vsadm.o] エラー 1

g++ -DHAVE_CONFIG_H -I. -I../.. -O2 -fno-strict-aliasing -g -Wall
-Werror -pthread -I../include -I../include
-DL7VS_MODULE_PATH="\"/usr/lib64/l7vs\"" -DMAX_BUFFER_SIZE=4096
-DPARAMETER_FILE="\"/etc/l7vs/l7vs.cf\""
-DL7VS_CONFIG_SOCK_PATH="\"/var/run/l7vs\"" -DLOGGER_PROCESS_VSD
-DNETSNMP_NO_INLINE -DVERSION=\"3.0.4\" -g -O2 -MT
l7vsd-protocol_module_control.o -MD -MP -MF
.deps/l7vsd-protocol_module_control.Tpo -c -o
l7vsd-protocol_module_control.o `test -f 'protocol_module_control.cpp'
|| echo './'`protocol_module_control.cpp
session_thread_control.cpp: In member function ‘void
l7vs::session_thread_control::start_thread()’:
session_thread_control.cpp:39:24: error: variable ‘int_val’ set but not
used [-Werror=unused-but-set-variable]
session_thread_control.cpp:45:16: error: variable ‘retval’ set but not
used [-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
make[3]: *** [l7vsd-session_thread_control.o] エラー 1
make[3]: *** 未完了のジョブを待っています....


g++ -DHAVE_CONFIG_H -I. -I../.. -O2 -fno-strict-aliasing -g -Wall
-Werror -pthread -I../include -I../include
-DL7VS_MODULE_PATH="\"/usr/lib64/l7vs\"" -DMAX_BUFFER_SIZE=4096
-DPARAMETER_FILE="\"/etc/l7vs/l7vs.cf\""
-DL7VS_CONFIG_SOCK_PATH="\"/var/run/l7vs\"" -DLOGGER_PROCESS_VSD
-DNETSNMP_NO_INLINE -DVERSION=\"3.0.4\" -g -O2 -MT
l7vsd-virtualservice_udp.o -MD -MP -MF
.deps/l7vsd-virtualservice_udp.Tpo -c -o l7vsd-virtualservice_udp.o
`test -f 'virtualservice_udp.cpp' || echo './'`virtualservice_udp.cpp
virtualservice_base.cpp: In member function ‘cpu_set_t
l7vs::virtualservice_base::get_cpu_mask(std::string)’:
virtualservice_base.cpp:484:33: error: variable ‘target_interrupt’ set
but not used [-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
make[3]: *** [l7vsd-virtualservice_base.o] エラー 1
make[3]: *** 未完了のジョブを待っています....


logger_a-logger_impl.o -MD -MP -MF
.deps/libl7vsd_logger_a-logger_impl.Tpo -c -o
libl7vsd_logger_a-logger_impl.o `test -f 'logger_impl.cpp' || echo
'./'`logger_impl.cpp
logger_impl.cpp: In member function ‘virtual bool l7vs::LoggerImpl::init()’:
logger_impl.cpp:346:20: error: variable ‘ret’ set but not used
[-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
make[3]: *** [libl7vsd_logger_a-logger_impl.o] エラー 1
make[3]: *** 未完了のジョブを待っています....

Ticket History (3/4 Histories)

2013-03-19 11:53 Updated by: tarusoopy
  • New Ticket "gcc4.6以降でのコンパイルエラー対処" created
2013-06-10 13:34 Updated by: tarusoopy
Comment
  • 余計なforwarded-forチェックは消し。
  • 意味不明コードも消し。
  • コンストラクタと変数定義を勘違いしたコードは修正。
  • ファイルロックのエラー処理に任せるのでreadlinkのエラーチェックは省略。
  • UMのホストネーム引けなくてもエラーにはしないようにする。
  • スレッドのパラメータ設定は、エラー処理を追加。

getとset共通のエラーであるESRCHは該当スレッドが落ちてたりしたときなので、 そのときは再度スレッドプールからスレッドをとって来るように。 setのときのEPERMはroot権限ないときなので、その旨をログ出力して例外を投げて エラー終了させる。 そのほかにはEINVALが返るともあるが、どうせSEGV時のエラーなのでcoreを吐くだろうと 思ってスルー。

  • cpu_maskは一応、使うかもしれないんでメモ代わりに残しておくことに。
2013-10-17 13:07 Updated by: hiroakinakano
  • Component Update from [1] UltraMonkey-L7 v3.0.4-3 to [1] UltraMonkey-L7 v3.1.0-1
  • Resolution Update from None to Fixed
  • Status Update from Open to Closed
  • Ticket Close date is changed to 2013-10-17 13:07
Comment

v3.1.0にて盛り込み

Attachment File List

Edit

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Login