llvm / llvm/llvm-project

[clang-tidy] bzero(3) is not bugprone nor unsafe

Open
#187,830 9 comments 0 reactions 0 assignees View on GitHub
clang-tidy false-positive question
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```
lmax.c:40:2: error: function 'bzero' is deprecated; 'memset' should be used instead [bugprone-unsafe-functions,cert-msc24-c,cert-msc33-c,-warnings-as-errors]
40 | bzero(arr_out, sizeof(arr_out[0][0]) * rows * cols);
| ^~~~~
```

It is true that bzero(3) is deprecated.

However, I can't agree with this being part of `bugprone-unsafe-functions`. It's ironic, because memset(3) is the bugprone and unsafe function. bzero(3) is a much safer thing than memset(3).

Should this diagnostic be called something else? Diagnosing deprecated stuff is significantly different from diagnosing bugprone/unsafe stuff.

Contributor guide

Open the contributing guide

Research direction

The report concerns clang-tidy's bugprone-unsafe-functions check and its diagnostic for bzero(3); start by locating that check and its test coverage. Compare the check's intended scope with the request to separate deprecation from unsafe-function diagnostics, then verify the final diagnostic category and behavior with the check's tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.