Hi Everyone/Tim,

I see this on occasion:

libwget_xml_parse_buffer_fuzzer.c: In function 'LLVMFuzzerTestOneInput':
libwget_xml_parse_buffer_fuzzer.c:65:2: warning: ignoring return value
of 'freopen', declared with attribute warn_unused_result
[-Wunused-result]
  freopen("/dev/null", "r", stdin);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I _think_ the way to handle that nowadays in a portable way is to:

    #define WGET_UNUSED(x) ((void)(x))
    int ret = freopen("/dev/null", "r", stdin);
    WGET_UNUSED(ret);

In the past a cast to void used to work. But it has not been working
lately, with GCC9 or GCC10, and it now generates a warning, too:

    (void)freopen("/dev/null", "r", stdin);

The WGET_UNUSED macro is really portable. You can also use it for
function parameters on all the compilers I test. (Unlike, say, a GCC
attribute).

Jeff

Reply via email to