staging: ks7010: remove auxiliar zeros buffer in ks_wlan_get_encode
authorSergio Paracuellos <sergio.paracuellos@gmail.com>
Thu, 19 Apr 2018 05:07:57 +0000 (07:07 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Apr 2018 12:32:04 +0000 (14:32 +0200)
commitfffe8becb7cf67c78f954721689e6906cc936c68
tree7618252bffea1d66047c024340f952abdf4233d1
parent5dcb7b1e982f31e408d6be6e810d631f38378403
staging: ks7010: remove auxiliar zeros buffer in ks_wlan_get_encode

This commit removes the local buffer zeros in ks_wlan_get_encode
function. It also refactors related conditions in order to fill
'extra' output parameter of the function. Originally this zeros
is just memset to zeros and only being used if drw->length is
truncated to zero because of priv->reg.wep_key[index].size is
greater than 16 chars. In those cases the final if statement is
just using zeros but it is using memcpy with a length of zero
bytes which has no sense. Instead of that just handle the good
case copying from the same source the number of bytes of
priv->reg.wep_key[index].size. If it is zero the final 'extra'
parameter won't be copied at all because the number of bytes to
copy will be zero. With this change the code gets simplified.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ks7010/ks_wlan_net.c