mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
coccinelle: similar to reallocarray() let's also systematically use malloc_multiply()
This commit is contained in:
parent
62d74c78b5
commit
8419d45776
20
coccinelle/malloc_multiply.cocci
Normal file
20
coccinelle/malloc_multiply.cocci
Normal file
@ -0,0 +1,20 @@
|
||||
@@
|
||||
expression q, n, m;
|
||||
@@
|
||||
- q = malloc((n)*(m))
|
||||
+ q = malloc_multiply(n, m)
|
||||
@@
|
||||
expression q, n, m;
|
||||
@@
|
||||
- q = malloc(n*(m))
|
||||
+ q = malloc_multiply(n, m)
|
||||
@@
|
||||
expression q, n, m;
|
||||
@@
|
||||
- q = malloc((n)*m)
|
||||
+ q = malloc_multiply(n, m)
|
||||
@@
|
||||
expression q, n, m;
|
||||
@@
|
||||
- q = malloc(n*m)
|
||||
+ q = malloc_multiply(n, m)
|
@ -1544,7 +1544,7 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) {
|
||||
udev_list_init(udev, &file_list, true);
|
||||
|
||||
/* init token array and string buffer */
|
||||
rules->tokens = malloc(PREALLOC_TOKEN * sizeof(struct token));
|
||||
rules->tokens = malloc_multiply(PREALLOC_TOKEN, sizeof(struct token));
|
||||
if (rules->tokens == NULL)
|
||||
return udev_rules_unref(rules);
|
||||
rules->token_max = PREALLOC_TOKEN;
|
||||
|
@ -248,7 +248,7 @@ static void setup_remaining_vcs(int src_fd, unsigned src_idx, bool utf8) {
|
||||
* requries 32 per glyph, regardless of the actual height - see the comment above #define
|
||||
* max_font_size 65536 in drivers/tty/vt/vt.c for more details.
|
||||
*/
|
||||
fontbuf = malloc((cfo.width + 7) / 8 * 32 * cfo.charcount);
|
||||
fontbuf = malloc_multiply((cfo.width + 7) / 8 * 32, cfo.charcount);
|
||||
if (!fontbuf) {
|
||||
log_oom();
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user