Since 'sprintf()' returns the number of characters emitted, an extra calls to 'strlen()' in 'ieee80211_bss()' may be dropped.
Unified · Split
| @@ -3422,59 +3422,63 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, · 3421 unmodified lines | ||
| 3422 | 3422 | cfg = (u8 *)ie + 2; |
| 3423 | 3423 | memset(&iwe, 0, sizeof(iwe)); |
| 3424 | 3424 | 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]); | |
| 3428 | 3428 | current_ev = iwe_stream_add_point_check(info, |
| 3429 | 3429 | current_ev, |
| 3430 | 3430 | end_buf, |
| 3431 | 3431 | &iwe, buf); |
| 3432 | 3432 | if (IS_ERR(current_ev)) |
| 3433 | 3433 | 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]); | |
| 3437 | 3437 | current_ev = iwe_stream_add_point_check(info, |
| 3438 | 3438 | current_ev, |
| 3439 | 3439 | end_buf, |
| 3440 | 3440 | &iwe, buf); |
| 3441 | 3441 | if (IS_ERR(current_ev)) |
| 3442 | 3442 | 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]); | |
| 3446 | 3446 | current_ev = iwe_stream_add_point_check(info, |
| 3447 | 3447 | current_ev, |
| 3448 | 3448 | end_buf, |
| 3449 | 3449 | &iwe, buf); |
| 3450 | 3450 | if (IS_ERR(current_ev)) |
| 3451 | 3451 | 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]); | |
| 3454 | 3455 | current_ev = iwe_stream_add_point_check(info, |
| 3455 | 3456 | current_ev, |
| 3456 | 3457 | end_buf, |
| 3457 | 3458 | &iwe, buf); |
| 3458 | 3459 | if (IS_ERR(current_ev)) |
| 3459 | 3460 | 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]); | |
| 3462 | 3464 | current_ev = iwe_stream_add_point_check(info, |
| 3463 | 3465 | current_ev, |
| 3464 | 3466 | end_buf, |
| 3465 | 3467 | &iwe, buf); |
| 3466 | 3468 | if (IS_ERR(current_ev)) |
| 3467 | 3469 | 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]); | |
| 3470 | 3473 | current_ev = iwe_stream_add_point_check(info, |
| 3471 | 3474 | current_ev, |
| 3472 | 3475 | end_buf, |
| 3473 | 3476 | &iwe, buf); |
| 3474 | 3477 | if (IS_ERR(current_ev)) |
| 3475 | 3478 | 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]); | |
| 3478 | 3482 | current_ev = iwe_stream_add_point_check(info, |
| 3479 | 3483 | current_ev, |
| 3480 | 3484 | end_buf, |
| @@ -3530,17 +3534,16 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, · 49 unmodified lines | ||
| 3530 | 3534 | |
| 3531 | 3535 | memset(&iwe, 0, sizeof(iwe)); |
| 3532 | 3536 | 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)); | |
| 3535 | 3539 | current_ev = iwe_stream_add_point_check(info, current_ev, end_buf, |
| 3536 | 3540 | &iwe, buf); |
| 3537 | 3541 | if (IS_ERR(current_ev)) |
| 3538 | 3542 | goto unlock; |
| 3539 | 3543 | memset(&iwe, 0, sizeof(iwe)); |
| 3540 | 3544 | 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)); | |
| 3544 | 3547 | current_ev = iwe_stream_add_point_check(info, current_ev, |
| 3545 | 3548 | end_buf, &iwe, buf); |
| 3546 | 3549 | if (IS_ERR(current_ev)) |