CC: [email protected] BCC: [email protected] CC: [email protected] TO: Luiz Augusto von Dentz <[email protected]> CC: Marcel Holtmann <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 30c8e80f79329617012f07b09b70114592092ea4 commit: 01ce70b0a274bd76a5a311fb90d4d446d9bdfea1 Bluetooth: eir: Move EIR/Adv Data functions to its own file date: 8 months ago :::::: branch date: 3 hours ago :::::: commit date: 8 months ago compiler: aarch64-linux-gcc (GCC) 11.3.0 reproduce (cppcheck warning): # apt-get install cppcheck git checkout 01ce70b0a274bd76a5a311fb90d4d446d9bdfea1 cppcheck --quiet --enable=style,performance,portability --template=gcc FILE If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> cppcheck possible warnings: (new ones prefixed by >>, may not real problems) >> net/bluetooth/eir.c:295:4: warning: Assignment of function parameter has no >> effect outside the function. Did you forget dereferencing it? >> [uselessAssignmentPtrArg] ptr += 3; ^ >> net/bluetooth/mgmt.c:9655:8: warning: Local variable 'flags' shadows outer >> argument [shadowArgument] u8 *flags = eir_get_data(eir, eir_len, EIR_FLAGS, NULL); ^ net/bluetooth/mgmt.c:9621:52: note: Shadowed declaration u8 addr_type, u8 *dev_class, s8 rssi, u32 flags, ^ net/bluetooth/mgmt.c:9655:8: note: Shadow variable u8 *flags = eir_get_data(eir, eir_len, EIR_FLAGS, NULL); ^ >> net/bluetooth/mgmt.c:7825:72: warning: Parameter 'data' can be declared with >> const [constParameter] static bool tlv_data_is_valid(struct hci_dev *hdev, u32 adv_flags, u8 *data, ^ >> net/bluetooth/mgmt.c:2047:16: warning: Uninitialized variable: cmd->opcode >> [uninitvar] switch (cmd->opcode) { ^ net/bluetooth/mgmt.c:2820:12: warning: Uninitialized variable: cmd->opcode [uninitvar] if (cmd->opcode != MGMT_OP_PAIR_DEVICE) ^ vim +295 net/bluetooth/eir.c 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 214 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 215 u8 eir_create_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr) 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 216 { 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 217 struct adv_info *adv = NULL; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 218 u8 ad_len = 0, flags = 0; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 219 u32 instance_flags; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 220 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 221 /* Return 0 when the current instance identifier is invalid. */ 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 222 if (instance) { 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 223 adv = hci_find_adv_instance(hdev, instance); 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 224 if (!adv) 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 225 return 0; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 226 } 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 227 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 228 instance_flags = hci_adv_instance_flags(hdev, instance); 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 229 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 230 /* If instance already has the flags set skip adding it once 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 231 * again. 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 232 */ 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 233 if (adv && eir_get_data(adv->adv_data, adv->adv_data_len, EIR_FLAGS, 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 234 NULL)) 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 235 goto skip_flags; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 236 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 237 /* The Add Advertising command allows userspace to set both the general 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 238 * and limited discoverable flags. 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 239 */ 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 240 if (instance_flags & MGMT_ADV_FLAG_DISCOV) 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 241 flags |= LE_AD_GENERAL; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 242 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 243 if (instance_flags & MGMT_ADV_FLAG_LIMITED_DISCOV) 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 244 flags |= LE_AD_LIMITED; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 245 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 246 if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 247 flags |= LE_AD_NO_BREDR; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 248 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 249 if (flags || (instance_flags & MGMT_ADV_FLAG_MANAGED_FLAGS)) { 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 250 /* If a discovery flag wasn't provided, simply use the global 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 251 * settings. 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 252 */ 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 253 if (!flags) 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 254 flags |= mgmt_get_adv_discov_flags(hdev); 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 255 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 256 /* If flags would still be empty, then there is no need to 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 257 * include the "Flags" AD field". 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 258 */ 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 259 if (flags) { 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 260 ptr[0] = 0x02; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 261 ptr[1] = EIR_FLAGS; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 262 ptr[2] = flags; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 263 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 264 ad_len += 3; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 265 ptr += 3; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 266 } 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 267 } 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 268 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 269 skip_flags: 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 270 if (adv) { 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 271 memcpy(ptr, adv->adv_data, adv->adv_data_len); 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 272 ad_len += adv->adv_data_len; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 273 ptr += adv->adv_data_len; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 274 } 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 275 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 276 if (instance_flags & MGMT_ADV_FLAG_TX_POWER) { 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 277 s8 adv_tx_power; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 278 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 279 if (ext_adv_capable(hdev)) { 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 280 if (adv) 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 281 adv_tx_power = adv->tx_power; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 282 else 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 283 adv_tx_power = hdev->adv_tx_power; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 284 } else { 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 285 adv_tx_power = hdev->adv_tx_power; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 286 } 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 287 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 288 /* Provide Tx Power only if we can provide a valid value for it */ 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 289 if (adv_tx_power != HCI_TX_POWER_INVALID) { 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 290 ptr[0] = 0x02; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 291 ptr[1] = EIR_TX_POWER; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 292 ptr[2] = (u8)adv_tx_power; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 293 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 294 ad_len += 3; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 @295 ptr += 3; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 296 } 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 297 } 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 298 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 299 return ad_len; 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 300 } 01ce70b0a274bd Luiz Augusto von Dentz 2021-09-20 301 -- 0-DAY CI Kernel Test Service https://01.org/lkp _______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
