[PATCH 1/3] hwsim: Support deleting hwsim by name.

Johannes Berg johannes
Fri Oct 24 13:27:04 PDT 2014


On Fri, 2014-10-24 at 08:37 -0700, greearb at candelatech.com wrote:

>      def destroy_radio(self, radio_id):
> -        attrs = [netlink.U32Attr(HWSIM_ATTR_RADIO_ID, radio_id)]
> +        try:
> +            int(radio_id)
> +            attrs = [netlink.U32Attr(HWSIM_ATTR_RADIO_ID, int(radio_id))]
> +        except ValueError:
> +            attrs = [netlink.NulStrAttr(HWSIM_ATTR_RADIO_NAME, radio_id)]

I'm not sure I support that "magic", in fact the valid string "0" would
be converted to an int here. If anything, you want typeof() or
something, but IMHO you should instead do

 def destroy_radio(self, index=None, name=None):
    [...]

and have the caller pass it by calling

 destroy_radio(index=12345)
or
 destroy_radio(name="phy0")

johannes




More information about the Hostap mailing list