* grub-core/kern/i386/qemu/init.c: Remove variable length arrays.

This commit is contained in:
Vladimir Serbinenko 2013-12-04 09:48:36 +01:00
parent 85eb579ad9
commit bb6e299ccb
2 changed files with 10 additions and 15 deletions

View file

@ -1,3 +1,7 @@
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/i386/qemu/init.c: Remove variable length arrays.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com> 2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/types.h: Declare all byteswaps as inline functions * include/grub/types.h: Declare all byteswaps as inline functions

View file

@ -96,17 +96,8 @@ struct iterator_ctx
grub_size_t nresources; grub_size_t nresources;
}; };
static int /* We don't support bridges, so can't have more than 32 devices. */
count_cards (grub_pci_device_t dev __attribute__ ((unused)), #define MAX_DEVICES 32
grub_pci_id_t pciid __attribute__ ((unused)),
void *data)
{
int *cnt = data;
(*cnt)++;
return 0;
}
static int static int
find_resources (grub_pci_device_t dev, find_resources (grub_pci_device_t dev,
@ -116,6 +107,9 @@ find_resources (grub_pci_device_t dev,
struct iterator_ctx *ctx = data; struct iterator_ctx *ctx = data;
int bar; int bar;
if (ctx->nresources >= MAX_DEVICES * 6)
return 1;
for (bar = 0; bar < 6; bar++) for (bar = 0; bar < 6; bar++)
{ {
grub_pci_address_t addr; grub_pci_address_t addr;
@ -190,13 +184,10 @@ enable_cards (grub_pci_device_t dev,
static void static void
grub_pci_assign_addresses (void) grub_pci_assign_addresses (void)
{ {
int ncards = 0;
struct iterator_ctx ctx; struct iterator_ctx ctx;
grub_pci_iterate (count_cards, &ncards);
{ {
struct resource resources[ncards * 6]; struct resource resources[MAX_DEVICES * 6];
int done; int done;
unsigned i; unsigned i;
ctx.nresources = 0; ctx.nresources = 0;