History

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.

Dmitry Antipov committed 3 years ago

Commit 22446b71 parent 8c73d521 file · +25 −22Browse files

Unified · Split

net/wireless/scan.c+25−22
@@ -3422,59 +3422,63 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, · 3421 unmodified lines
34223422 cfg = (u8 *)ie + 2;
34233423 memset(&iwe, 0, sizeof(iwe));
34243424 iwe.cmd = IWEVCUSTOM;
3425− sprintf(buf, "Mesh Network Path Selection Protocol ID: "
3426− "0x%02X", cfg[0]);
3427− iwe.u.data.length = strlen(buf);
3425+ iwe.u.data.length = sprintf(buf,
3426+ "Mesh Network Path Selection Protocol ID: 0x%02X",
3427+ cfg[0]);
34283428 current_ev = iwe_stream_add_point_check(info,
34293429 current_ev,
34303430 end_buf,
34313431 &iwe, buf);
34323432 if (IS_ERR(current_ev))
34333433 goto unlock;
3434− sprintf(buf, "Path Selection Metric ID: 0x%02X",
3435− cfg[1]);
3436− iwe.u.data.length = strlen(buf);
3434+ iwe.u.data.length = sprintf(buf,
3435+ "Path Selection Metric ID: 0x%02X",
3436+ cfg[1]);
34373437 current_ev = iwe_stream_add_point_check(info,
34383438 current_ev,
34393439 end_buf,
34403440 &iwe, buf);
34413441 if (IS_ERR(current_ev))
34423442 goto unlock;
3443− sprintf(buf, "Congestion Control Mode ID: 0x%02X",
3444− cfg[2]);
3445− iwe.u.data.length = strlen(buf);
3443+ iwe.u.data.length = sprintf(buf,
3444+ "Congestion Control Mode ID: 0x%02X",
3445+ cfg[2]);
34463446 current_ev = iwe_stream_add_point_check(info,
34473447 current_ev,
34483448 end_buf,
34493449 &iwe, buf);
34503450 if (IS_ERR(current_ev))
34513451 goto unlock;
3452− sprintf(buf, "Synchronization ID: 0x%02X", cfg[3]);
3453− iwe.u.data.length = strlen(buf);
3452+ iwe.u.data.length = sprintf(buf,
3453+ "Synchronization ID: 0x%02X",
3454+ cfg[3]);
34543455 current_ev = iwe_stream_add_point_check(info,
34553456 current_ev,
34563457 end_buf,
34573458 &iwe, buf);
34583459 if (IS_ERR(current_ev))
34593460 goto unlock;
3460− sprintf(buf, "Authentication ID: 0x%02X", cfg[4]);
3461− iwe.u.data.length = strlen(buf);
3461+ iwe.u.data.length = sprintf(buf,
3462+ "Authentication ID: 0x%02X",
3463+ cfg[4]);
34623464 current_ev = iwe_stream_add_point_check(info,
34633465 current_ev,
34643466 end_buf,
34653467 &iwe, buf);
34663468 if (IS_ERR(current_ev))
34673469 goto unlock;
3468− sprintf(buf, "Formation Info: 0x%02X", cfg[5]);
3469− iwe.u.data.length = strlen(buf);
3470+ iwe.u.data.length = sprintf(buf,
3471+ "Formation Info: 0x%02X",
3472+ cfg[5]);
34703473 current_ev = iwe_stream_add_point_check(info,
34713474 current_ev,
34723475 end_buf,
34733476 &iwe, buf);
34743477 if (IS_ERR(current_ev))
34753478 goto unlock;
3476− sprintf(buf, "Capabilities: 0x%02X", cfg[6]);
3477− iwe.u.data.length = strlen(buf);
3479+ iwe.u.data.length = sprintf(buf,
3480+ "Capabilities: 0x%02X",
3481+ cfg[6]);
34783482 current_ev = iwe_stream_add_point_check(info,
34793483 current_ev,
34803484 end_buf,
@@ -3530,17 +3534,16 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, · 49 unmodified lines
35303534
35313535 memset(&iwe, 0, sizeof(iwe));
35323536 iwe.cmd = IWEVCUSTOM;
3533− sprintf(buf, "tsf=%016llx", (unsigned long long)(ies->tsf));
3534− iwe.u.data.length = strlen(buf);
3537+ iwe.u.data.length = sprintf(buf, "tsf=%016llx",
3538+ (unsigned long long)(ies->tsf));
35353539 current_ev = iwe_stream_add_point_check(info, current_ev, end_buf,
35363540 &iwe, buf);
35373541 if (IS_ERR(current_ev))
35383542 goto unlock;
35393543 memset(&iwe, 0, sizeof(iwe));
35403544 iwe.cmd = IWEVCUSTOM;
3541− sprintf(buf, " Last beacon: %ums ago",
3542− elapsed_jiffies_msecs(bss->ts));
3543− iwe.u.data.length = strlen(buf);
3545+ iwe.u.data.length = sprintf(buf, " Last beacon: %ums ago",
3546+ elapsed_jiffies_msecs(bss->ts));
35443547 current_ev = iwe_stream_add_point_check(info, current_ev,
35453548 end_buf, &iwe, buf);
35463549 if (IS_ERR(current_ev))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t