mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-17 18:34:03 -05:00
P2P: Split p2p_channels_union() into two functions
The separate p2p_channels_union_inplace() makes the function easier for static analyzers to see that the result buffer is always initialized. (CID 74494) Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
2f816c212c
commit
a6306bcc92
@ -1366,8 +1366,8 @@ int p2p_prepare_channel(struct p2p_data *p2p, struct p2p_device *dev,
|
|||||||
if (go)
|
if (go)
|
||||||
p2p_channels_remove_freqs(&p2p->channels, &p2p->no_go_freq);
|
p2p_channels_remove_freqs(&p2p->channels, &p2p->no_go_freq);
|
||||||
else if (!force_freq)
|
else if (!force_freq)
|
||||||
p2p_channels_union(&p2p->channels, &p2p->cfg->cli_channels,
|
p2p_channels_union_inplace(&p2p->channels,
|
||||||
&p2p->channels);
|
&p2p->cfg->cli_channels);
|
||||||
p2p_channels_dump(p2p, "after go/cli filter/add", &p2p->channels);
|
p2p_channels_dump(p2p, "after go/cli filter/add", &p2p->channels);
|
||||||
|
|
||||||
p2p_dbg(p2p, "Own preference for operation channel: Operating Class %u Channel %u%s",
|
p2p_dbg(p2p, "Own preference for operation channel: Operating Class %u Channel %u%s",
|
||||||
|
@ -613,6 +613,8 @@ int p2p_freq_to_channel(unsigned int freq, u8 *op_class, u8 *channel);
|
|||||||
void p2p_channels_intersect(const struct p2p_channels *a,
|
void p2p_channels_intersect(const struct p2p_channels *a,
|
||||||
const struct p2p_channels *b,
|
const struct p2p_channels *b,
|
||||||
struct p2p_channels *res);
|
struct p2p_channels *res);
|
||||||
|
void p2p_channels_union_inplace(struct p2p_channels *res,
|
||||||
|
const struct p2p_channels *b);
|
||||||
void p2p_channels_union(const struct p2p_channels *a,
|
void p2p_channels_union(const struct p2p_channels *a,
|
||||||
const struct p2p_channels *b,
|
const struct p2p_channels *b,
|
||||||
struct p2p_channels *res);
|
struct p2p_channels *res);
|
||||||
|
@ -193,20 +193,15 @@ static void p2p_op_class_union(struct p2p_reg_class *cl,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* p2p_channels_union - Union of channel lists
|
* p2p_channels_union_inplace - Inplace union of channel lists
|
||||||
* @a: First set of channels
|
* @res: Input data and place for returning union of the channel sets
|
||||||
* @b: Second set of channels
|
* @b: Second set of channels
|
||||||
* @res: Data structure for returning the union of channels
|
|
||||||
*/
|
*/
|
||||||
void p2p_channels_union(const struct p2p_channels *a,
|
void p2p_channels_union_inplace(struct p2p_channels *res,
|
||||||
const struct p2p_channels *b,
|
const struct p2p_channels *b)
|
||||||
struct p2p_channels *res)
|
|
||||||
{
|
{
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
|
|
||||||
if (a != res)
|
|
||||||
os_memcpy(res, a, sizeof(*res));
|
|
||||||
|
|
||||||
for (i = 0; i < res->reg_classes; i++) {
|
for (i = 0; i < res->reg_classes; i++) {
|
||||||
struct p2p_reg_class *cl = &res->reg_class[i];
|
struct p2p_reg_class *cl = &res->reg_class[i];
|
||||||
for (j = 0; j < b->reg_classes; j++) {
|
for (j = 0; j < b->reg_classes; j++) {
|
||||||
@ -236,6 +231,21 @@ void p2p_channels_union(const struct p2p_channels *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* p2p_channels_union - Union of channel lists
|
||||||
|
* @a: First set of channels
|
||||||
|
* @b: Second set of channels
|
||||||
|
* @res: Data structure for returning the union of channels
|
||||||
|
*/
|
||||||
|
void p2p_channels_union(const struct p2p_channels *a,
|
||||||
|
const struct p2p_channels *b,
|
||||||
|
struct p2p_channels *res)
|
||||||
|
{
|
||||||
|
os_memcpy(res, a, sizeof(*res));
|
||||||
|
p2p_channels_union_inplace(res, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void p2p_channels_remove_freqs(struct p2p_channels *chan,
|
void p2p_channels_remove_freqs(struct p2p_channels *chan,
|
||||||
const struct wpa_freq_range_list *list)
|
const struct wpa_freq_range_list *list)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user