| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* -*- mode: c; c-basic-offset: 8; -*- |
|---|
| 2 | 3 | * vim: noexpandtab sw=8 ts=8 sts=0: |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * slot_map.c |
|---|
| 5 | 6 | * |
|---|
| 6 | | - * |
|---|
| 7 | | - * |
|---|
| 8 | 7 | * Copyright (C) 2002, 2004 Oracle. All rights reserved. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or |
|---|
| 11 | | - * modify it under the terms of the GNU General Public |
|---|
| 12 | | - * License as published by the Free Software Foundation; either |
|---|
| 13 | | - * version 2 of the License, or (at your option) any later version. |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 18 | | - * General Public License for more details. |
|---|
| 19 | | - * |
|---|
| 20 | | - * You should have received a copy of the GNU General Public |
|---|
| 21 | | - * License along with this program; if not, write to the |
|---|
| 22 | | - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|---|
| 23 | | - * Boston, MA 021110-1307, USA. |
|---|
| 24 | 8 | */ |
|---|
| 25 | 9 | |
|---|
| 26 | 10 | #include <linux/types.h> |
|---|
| .. | .. |
|---|
| 55 | 39 | unsigned int si_blocks; |
|---|
| 56 | 40 | struct buffer_head **si_bh; |
|---|
| 57 | 41 | unsigned int si_num_slots; |
|---|
| 58 | | - struct ocfs2_slot *si_slots; |
|---|
| 42 | + struct ocfs2_slot si_slots[]; |
|---|
| 59 | 43 | }; |
|---|
| 60 | 44 | |
|---|
| 61 | 45 | |
|---|
| .. | .. |
|---|
| 420 | 404 | struct inode *inode = NULL; |
|---|
| 421 | 405 | struct ocfs2_slot_info *si; |
|---|
| 422 | 406 | |
|---|
| 423 | | - si = kzalloc(sizeof(struct ocfs2_slot_info) + |
|---|
| 424 | | - (sizeof(struct ocfs2_slot) * osb->max_slots), |
|---|
| 425 | | - GFP_KERNEL); |
|---|
| 407 | + si = kzalloc(struct_size(si, si_slots, osb->max_slots), GFP_KERNEL); |
|---|
| 426 | 408 | if (!si) { |
|---|
| 427 | 409 | status = -ENOMEM; |
|---|
| 428 | 410 | mlog_errno(status); |
|---|
| .. | .. |
|---|
| 431 | 413 | |
|---|
| 432 | 414 | si->si_extended = ocfs2_uses_extended_slot_map(osb); |
|---|
| 433 | 415 | si->si_num_slots = osb->max_slots; |
|---|
| 434 | | - si->si_slots = (struct ocfs2_slot *)((char *)si + |
|---|
| 435 | | - sizeof(struct ocfs2_slot_info)); |
|---|
| 436 | 416 | |
|---|
| 437 | 417 | inode = ocfs2_get_system_file_inode(osb, SLOT_MAP_SYSTEM_INODE, |
|---|
| 438 | 418 | OCFS2_INVALID_SLOT); |
|---|