mirror of
https://github.com/linux-usb-gadgets/libusbgx.git
synced 2025-07-12 22:59:43 +03:00
include: function: net: Fix narrowing integer conversions
This fixes the following compilation error/warning: In file included from ../tests/header_checker.cpp:6: ../include/usbg/function/net.h: In function ‘int usbg_f_net_set_subclass(usbg_f_net*, unsigned int)’: ../include/usbg/function/net.h:278:67: error: narrowing conversion of ‘subclass’ from ‘unsigned int’ to ‘int’ [-Werror=narrowing] 278 | USBG_F_NET_INT_TO_ATTR_VAL(subclass)); | ^~~~~~~~ ../include/usbg/usbg.h:61:34: note: in definition of macro ‘USBG_TO_UNION’ 61 | ((union UNAME){ .FIELD = WHAT, }) | ^~~~ ../include/usbg/function/net.h:278:40: note: in expansion of macro ‘USBG_F_NET_INT_TO_ATTR_VAL’ 278 | USBG_F_NET_INT_TO_ATTR_VAL(subclass)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/usbg/function/net.h: In function ‘int usbg_f_net_set_protocol(usbg_f_net*, unsigned int)’: ../include/usbg/function/net.h:302:67: error: narrowing conversion of ‘protocol’ from ‘unsigned int’ to ‘int’ [-Werror=narrowing] 302 | USBG_F_NET_INT_TO_ATTR_VAL(protocol)); | ^~~~~~~~ ../include/usbg/usbg.h:61:34: note: in definition of macro ‘USBG_TO_UNION’ 61 | ((union UNAME){ .FIELD = WHAT, }) | ^~~~ ../include/usbg/function/net.h:302:40: note: in expansion of macro ‘USBG_F_NET_INT_TO_ATTR_VAL’ 302 | USBG_F_NET_INT_TO_ATTR_VAL(protocol)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors In the kernel qmult is also from type unsigned int which alignes with the rest of this struct and resolves the above compile issue.
This commit is contained in:
parent
bad649b200
commit
8664b79d12
1 changed files with 3 additions and 3 deletions
|
@ -50,7 +50,7 @@ union usbg_f_net_attr_val {
|
|||
struct ether_addr dev_addr;
|
||||
struct ether_addr host_addr;
|
||||
const char *ifname;
|
||||
int qmult;
|
||||
unsigned int qmult;
|
||||
unsigned int class_;
|
||||
unsigned int subclass;
|
||||
unsigned int protocol;
|
||||
|
@ -212,7 +212,7 @@ int usbg_f_net_get_ifname_s(usbg_f_net *nf, char *buf, int len);
|
|||
* @param[out] qmult Current multiplier of queue len
|
||||
* @return 0 on success usbg_error if error occurred.
|
||||
*/
|
||||
static inline int usbg_f_net_get_qmult(usbg_f_net *nf, int *qmult)
|
||||
static inline int usbg_f_net_get_qmult(usbg_f_net *nf, unsigned int *qmult)
|
||||
{
|
||||
return usbg_f_net_get_attr_val(nf, USBG_F_NET_QMULT,
|
||||
(union usbg_f_net_attr_val *)qmult);
|
||||
|
@ -224,7 +224,7 @@ static inline int usbg_f_net_get_qmult(usbg_f_net *nf, int *qmult)
|
|||
* @param[in] qmult Multiplier of queue len which should be set
|
||||
* @return 0 on success usbg_error if error occurred.
|
||||
*/
|
||||
static inline int usbg_f_net_set_qmult(usbg_f_net *nf, int qmult)
|
||||
static inline int usbg_f_net_set_qmult(usbg_f_net *nf, unsigned int qmult)
|
||||
{
|
||||
return usbg_f_net_set_attr_val(nf, USBG_F_NET_QMULT,
|
||||
USBG_F_NET_INT_TO_ATTR_VAL(qmult));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue