同じ構成 (fifo ファイル) でアプリケーションの 2 つのインスタンスを実行しないようにする関数を記述します。
if( !filename_specified ) {
char *fifofile = get_fifo_filename( config_get_uid( ct ) );
int fifofd;
if( !fifofile ) {
lfprintf( stderr, _("%s: Cannot allocate memory.\n"), argv[ 0 ] );
return 0;
}
/* negative_return_fn: Function "open(fifofile, 2049)" returns a negative number */
fifofd = open( fifofile, O_WRONLY | O_NONBLOCK );
if( fifofd >= 0 ) {
lfprintf( stderr, _("Cannot run two instances of application with the same configuration.\n") );
close( fifofd );
return 0;
}
/* negative_returns: "fifofd" is passed to a parameter that cannot be negative */
close( fifofd );
}
私のコードはこの警告を受け取ります:
正の値を期待する関数の引数として負の値が使用されました。