coccinelle: similar to reallocarray() let's also systematically use malloc_multiply()

This commit is contained in:
Lennart Poettering 2018-02-27 19:16:47 +01:00
parent 62d74c78b5
commit 8419d45776
3 changed files with 22 additions and 2 deletions

View 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)

View File

@ -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;

View File

@ -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;