mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
signal.c: make signame_prefix a nul-terminated string
gcc 9.1.0 warns this.
```
signal.c:258:46: warning: '%.*s' directive argument is not a nul-terminated string [-Wformat-overflow=]
258 | rb_raise(rb_eArgError, "unsupported signal `%.*s%"PRIsVALUE"'",
| ^~~~
259 | prefix, signame_prefix, vsig);
| ~~~~~~~~~~~~~~
signal.c:200:19: note: referenced argument declared here
200 | static const char signame_prefix[3] = "SIG";
| ^~~~~~~~~~~~~~
```
https://rubyci.org/logs/rubyci.s3.amazonaws.com/ubuntu/ruby-master/log/20190801T033009Z.log.html.gz
This commit is contained in:
parent
7463867106
commit
f45bb760fb
1 changed files with 3 additions and 3 deletions
6
signal.c
6
signal.c
|
|
@ -197,8 +197,8 @@ static const struct signals {
|
|||
#endif
|
||||
};
|
||||
|
||||
static const char signame_prefix[3] = "SIG";
|
||||
static const int signame_prefix_len = (int)sizeof(signame_prefix);
|
||||
static const char signame_prefix[] = "SIG";
|
||||
static const int signame_prefix_len = 3;
|
||||
|
||||
static int
|
||||
signm2signo(VALUE *sig_ptr, int negative, int exit, int *prefix_ptr)
|
||||
|
|
@ -236,7 +236,7 @@ signm2signo(VALUE *sig_ptr, int negative, int exit, int *prefix_ptr)
|
|||
negative = 0;
|
||||
}
|
||||
if (len >= prefix + signame_prefix_len) {
|
||||
if (memcmp(nm + prefix, signame_prefix, sizeof(signame_prefix)) == 0)
|
||||
if (memcmp(nm + prefix, signame_prefix, signame_prefix_len) == 0)
|
||||
prefix += signame_prefix_len;
|
||||
}
|
||||
if (len <= (long)prefix) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue