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
3422 cfg = (u8 *)ie + 2;3422 cfg = (u8 *)ie + 2;
3423 memset(&iwe, 0, sizeof(iwe));3423 memset(&iwe, 0, sizeof(iwe));
3424 iwe.cmd = IWEVCUSTOM;3424 iwe.cmd = IWEVCUSTOM;
3425 sprintf(buf, "Mesh Network Path Selection Protocol ID: "3425 iwe.u.data.length = sprintf(buf,
3426 "0x%02X", cfg[0]);3426 "Mesh Network Path Selection Protocol ID: 0x%02X",
3427 iwe.u.data.length = strlen(buf);3427 cfg[0]);
3428 current_ev = iwe_stream_add_point_check(info,3428 current_ev = iwe_stream_add_point_check(info,
3429 current_ev,3429 current_ev,
3430 end_buf,3430 end_buf,
3431 &iwe, buf);3431 &iwe, buf);
3432 if (IS_ERR(current_ev))3432 if (IS_ERR(current_ev))
3433 goto unlock;3433 goto unlock;
3434 sprintf(buf, "Path Selection Metric ID: 0x%02X",3434 iwe.u.data.length = sprintf(buf,
3435 cfg[1]);3435 "Path Selection Metric ID: 0x%02X",
3436 iwe.u.data.length = strlen(buf);3436 cfg[1]);
3437 current_ev = iwe_stream_add_point_check(info,3437 current_ev = iwe_stream_add_point_check(info,
3438 current_ev,3438 current_ev,
3439 end_buf,3439 end_buf,
3440 &iwe, buf);3440 &iwe, buf);
3441 if (IS_ERR(current_ev))3441 if (IS_ERR(current_ev))
3442 goto unlock;3442 goto unlock;
3443 sprintf(buf, "Congestion Control Mode ID: 0x%02X",3443 iwe.u.data.length = sprintf(buf,
3444 cfg[2]);3444 "Congestion Control Mode ID: 0x%02X",
3445 iwe.u.data.length = strlen(buf);3445 cfg[2]);
3446 current_ev = iwe_stream_add_point_check(info,3446 current_ev = iwe_stream_add_point_check(info,
3447 current_ev,3447 current_ev,
3448 end_buf,3448 end_buf,
3449 &iwe, buf);3449 &iwe, buf);
3450 if (IS_ERR(current_ev))3450 if (IS_ERR(current_ev))
3451 goto unlock;3451 goto unlock;
3452 sprintf(buf, "Synchronization ID: 0x%02X", cfg[3]);3452 iwe.u.data.length = sprintf(buf,
3453 iwe.u.data.length = strlen(buf);3453 "Synchronization ID: 0x%02X",
3454 cfg[3]);
3454 current_ev = iwe_stream_add_point_check(info,3455 current_ev = iwe_stream_add_point_check(info,
3455 current_ev,3456 current_ev,
3456 end_buf,3457 end_buf,
3457 &iwe, buf);3458 &iwe, buf);
3458 if (IS_ERR(current_ev))3459 if (IS_ERR(current_ev))
3459 goto unlock;3460 goto unlock;
3460 sprintf(buf, "Authentication ID: 0x%02X", cfg[4]);3461 iwe.u.data.length = sprintf(buf,
3461 iwe.u.data.length = strlen(buf);3462 "Authentication ID: 0x%02X",
3463 cfg[4]);
3462 current_ev = iwe_stream_add_point_check(info,3464 current_ev = iwe_stream_add_point_check(info,
3463 current_ev,3465 current_ev,
3464 end_buf,3466 end_buf,
3465 &iwe, buf);3467 &iwe, buf);
3466 if (IS_ERR(current_ev))3468 if (IS_ERR(current_ev))
3467 goto unlock;3469 goto unlock;
3468 sprintf(buf, "Formation Info: 0x%02X", cfg[5]);3470 iwe.u.data.length = sprintf(buf,
3469 iwe.u.data.length = strlen(buf);3471 "Formation Info: 0x%02X",
3472 cfg[5]);
3470 current_ev = iwe_stream_add_point_check(info,3473 current_ev = iwe_stream_add_point_check(info,
3471 current_ev,3474 current_ev,
3472 end_buf,3475 end_buf,
3473 &iwe, buf);3476 &iwe, buf);
3474 if (IS_ERR(current_ev))3477 if (IS_ERR(current_ev))
3475 goto unlock;3478 goto unlock;
3476 sprintf(buf, "Capabilities: 0x%02X", cfg[6]);3479 iwe.u.data.length = sprintf(buf,
3477 iwe.u.data.length = strlen(buf);3480 "Capabilities: 0x%02X",
3481 cfg[6]);
3478 current_ev = iwe_stream_add_point_check(info,3482 current_ev = iwe_stream_add_point_check(info,
3479 current_ev,3483 current_ev,
3480 end_buf,3484 end_buf,
@@ -3530,17 +3534,16 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, · 49 unmodified lines
3530 3534
3531 memset(&iwe, 0, sizeof(iwe));3535 memset(&iwe, 0, sizeof(iwe));
3532 iwe.cmd = IWEVCUSTOM;3536 iwe.cmd = IWEVCUSTOM;
3533 sprintf(buf, "tsf=%016llx", (unsigned long long)(ies->tsf));3537 iwe.u.data.length = sprintf(buf, "tsf=%016llx",
3534 iwe.u.data.length = strlen(buf);3538 (unsigned long long)(ies->tsf));
3535 current_ev = iwe_stream_add_point_check(info, current_ev, end_buf,3539 current_ev = iwe_stream_add_point_check(info, current_ev, end_buf,
3536 &iwe, buf);3540 &iwe, buf);
3537 if (IS_ERR(current_ev))3541 if (IS_ERR(current_ev))
3538 goto unlock;3542 goto unlock;
3539 memset(&iwe, 0, sizeof(iwe));3543 memset(&iwe, 0, sizeof(iwe));
3540 iwe.cmd = IWEVCUSTOM;3544 iwe.cmd = IWEVCUSTOM;
3541 sprintf(buf, " Last beacon: %ums ago",3545 iwe.u.data.length = sprintf(buf, " Last beacon: %ums ago",
3542 elapsed_jiffies_msecs(bss->ts));3546 elapsed_jiffies_msecs(bss->ts));
3543 iwe.u.data.length = strlen(buf);
3544 current_ev = iwe_stream_add_point_check(info, current_ev,3547 current_ev = iwe_stream_add_point_check(info, current_ev,
3545 end_buf, &iwe, buf);3548 end_buf, &iwe, buf);
3546 if (IS_ERR(current_ev))3549 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