Commit 22446b7e authored by Dmitry Antipov's avatar Dmitry Antipov Committed by Johannes Berg

wifi: wext: avoid extra calls to strlen() in ieee80211_bss()

Since 'sprintf()' returns the number of characters emitted, an
extra calls to 'strlen()' in 'ieee80211_bss()' may be dropped.
Signed-off-by: default avatarDmitry Antipov <dmantipov@yandex.ru>
Link: https://lore.kernel.org/r/20230912035522.15947-1-dmantipov@yandex.ruSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 8c73d524
...@@ -3422,59 +3422,63 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, ...@@ -3422,59 +3422,63 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info,
cfg = (u8 *)ie + 2; cfg = (u8 *)ie + 2;
memset(&iwe, 0, sizeof(iwe)); memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVCUSTOM; iwe.cmd = IWEVCUSTOM;
sprintf(buf, "Mesh Network Path Selection Protocol ID: " iwe.u.data.length = sprintf(buf,
"0x%02X", cfg[0]); "Mesh Network Path Selection Protocol ID: 0x%02X",
iwe.u.data.length = strlen(buf); cfg[0]);
current_ev = iwe_stream_add_point_check(info, current_ev = iwe_stream_add_point_check(info,
current_ev, current_ev,
end_buf, end_buf,
&iwe, buf); &iwe, buf);
if (IS_ERR(current_ev)) if (IS_ERR(current_ev))
goto unlock; goto unlock;
sprintf(buf, "Path Selection Metric ID: 0x%02X", iwe.u.data.length = sprintf(buf,
cfg[1]); "Path Selection Metric ID: 0x%02X",
iwe.u.data.length = strlen(buf); cfg[1]);
current_ev = iwe_stream_add_point_check(info, current_ev = iwe_stream_add_point_check(info,
current_ev, current_ev,
end_buf, end_buf,
&iwe, buf); &iwe, buf);
if (IS_ERR(current_ev)) if (IS_ERR(current_ev))
goto unlock; goto unlock;
sprintf(buf, "Congestion Control Mode ID: 0x%02X", iwe.u.data.length = sprintf(buf,
cfg[2]); "Congestion Control Mode ID: 0x%02X",
iwe.u.data.length = strlen(buf); cfg[2]);
current_ev = iwe_stream_add_point_check(info, current_ev = iwe_stream_add_point_check(info,
current_ev, current_ev,
end_buf, end_buf,
&iwe, buf); &iwe, buf);
if (IS_ERR(current_ev)) if (IS_ERR(current_ev))
goto unlock; goto unlock;
sprintf(buf, "Synchronization ID: 0x%02X", cfg[3]); iwe.u.data.length = sprintf(buf,
iwe.u.data.length = strlen(buf); "Synchronization ID: 0x%02X",
cfg[3]);
current_ev = iwe_stream_add_point_check(info, current_ev = iwe_stream_add_point_check(info,
current_ev, current_ev,
end_buf, end_buf,
&iwe, buf); &iwe, buf);
if (IS_ERR(current_ev)) if (IS_ERR(current_ev))
goto unlock; goto unlock;
sprintf(buf, "Authentication ID: 0x%02X", cfg[4]); iwe.u.data.length = sprintf(buf,
iwe.u.data.length = strlen(buf); "Authentication ID: 0x%02X",
cfg[4]);
current_ev = iwe_stream_add_point_check(info, current_ev = iwe_stream_add_point_check(info,
current_ev, current_ev,
end_buf, end_buf,
&iwe, buf); &iwe, buf);
if (IS_ERR(current_ev)) if (IS_ERR(current_ev))
goto unlock; goto unlock;
sprintf(buf, "Formation Info: 0x%02X", cfg[5]); iwe.u.data.length = sprintf(buf,
iwe.u.data.length = strlen(buf); "Formation Info: 0x%02X",
cfg[5]);
current_ev = iwe_stream_add_point_check(info, current_ev = iwe_stream_add_point_check(info,
current_ev, current_ev,
end_buf, end_buf,
&iwe, buf); &iwe, buf);
if (IS_ERR(current_ev)) if (IS_ERR(current_ev))
goto unlock; goto unlock;
sprintf(buf, "Capabilities: 0x%02X", cfg[6]); iwe.u.data.length = sprintf(buf,
iwe.u.data.length = strlen(buf); "Capabilities: 0x%02X",
cfg[6]);
current_ev = iwe_stream_add_point_check(info, current_ev = iwe_stream_add_point_check(info,
current_ev, current_ev,
end_buf, end_buf,
...@@ -3530,17 +3534,16 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, ...@@ -3530,17 +3534,16 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info,
memset(&iwe, 0, sizeof(iwe)); memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVCUSTOM; iwe.cmd = IWEVCUSTOM;
sprintf(buf, "tsf=%016llx", (unsigned long long)(ies->tsf)); iwe.u.data.length = sprintf(buf, "tsf=%016llx",
iwe.u.data.length = strlen(buf); (unsigned long long)(ies->tsf));
current_ev = iwe_stream_add_point_check(info, current_ev, end_buf, current_ev = iwe_stream_add_point_check(info, current_ev, end_buf,
&iwe, buf); &iwe, buf);
if (IS_ERR(current_ev)) if (IS_ERR(current_ev))
goto unlock; goto unlock;
memset(&iwe, 0, sizeof(iwe)); memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVCUSTOM; iwe.cmd = IWEVCUSTOM;
sprintf(buf, " Last beacon: %ums ago", iwe.u.data.length = sprintf(buf, " Last beacon: %ums ago",
elapsed_jiffies_msecs(bss->ts)); elapsed_jiffies_msecs(bss->ts));
iwe.u.data.length = strlen(buf);
current_ev = iwe_stream_add_point_check(info, current_ev, current_ev = iwe_stream_add_point_check(info, current_ev,
end_buf, &iwe, buf); end_buf, &iwe, buf);
if (IS_ERR(current_ev)) if (IS_ERR(current_ev))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment