fix compile error and warning on freebsd