xmos / lib_spdif

S/PDIF Library
Other
10 stars 15 forks source link

Compiler warnings: "address of a resource handle" #30

Closed oscarbailey-xmos closed 1 month ago

oscarbailey-xmos commented 3 years ago
Compiling SpdifTransmit.xc
/home/oscar/sandboxes/usb_audio/lib_spdif/lib_spdif/src/SpdifTransmit.xc:861:29: warning: Taking the address of a resource handle, not the actual resource. Passing by (unsafe) value may be a better option [-Wunusual-code]
    out port * movable pp = &p_spdif;
                            ^~~~~~~~
Compiling spdif_rx.xc
/home/oscar/sandboxes/usb_audio/lib_spdif/lib_spdif/src/spdif_rx.xc:16:26: warning: Taking the address of a resource handle, not the actual resource. Passing by (unsafe) value may be a better option [-Wunusual-code]
  in port * movable pp = &p;
                         ^~

Found while compiling sw_usb_audio

xross commented 1 year ago

Note, this is as usage described in xs1.h:

/** Dynamically reconfigure the type of a port. 
 * 
 *  This builtin function reconfigures the type of a port. Its first argument 
 *  should be a movable pointer to a port. The second argument is the new 
 *  port type to reconfigure to. The return value is a movable pointer to the 
 *  new type of port. You can use the function as follows: 
 * 
 *  \code 
 *  void f(in port p) { 
 *    in port * movable pp = &p; 
 *    in buffered port:32 * movable q;
 *    q = reconfigure_port(move(pp), in buffered port:32);
 *
 *    // use *q here as a buffered port
 *
 *    pp = reconfigure_port(move(q), in port);
 *  }
 *  \endcode
 *
 *  When reconfiguring a port, all state (buffered input values etc.) on the
 *  port is lost.
 */
ed-xmos commented 4 months ago

I just want to add a strong +1 to this issue. It adds unnecessary console noise to the sw_usb_audio and lib_xua compilations. I'm sure this can be worked around.

xross commented 4 months ago

Couple of options

xross commented 4 months ago

My suggestion for a quick "fix" for the Tx one.

The Rx one is not in a separate function so needs pulling out more ideally? Or can just apply to the whole of spdif_rx.xc I suppose - its not much code.

xross commented 4 months ago

https://github.com/xmos/lib_spdif/pull/68