* grub-core/fs/nilfs2.c (grub_nilfs2_btree_node): Add zero-size keys

array.
	(grub_nilfs2_btree_node_dkeys): Ensure return pointer alignment.
	(grub_nilfs2_btree_lookup): Ensure buffer alignment.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-12-13 02:00:44 +01:00
parent 812e249302
commit eb561f3123
2 changed files with 12 additions and 4 deletions

View file

@ -1,3 +1,10 @@
2011-12-13 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/nilfs2.c (grub_nilfs2_btree_node): Add zero-size keys
array.
(grub_nilfs2_btree_node_dkeys): Ensure return pointer alignment.
(grub_nilfs2_btree_lookup): Ensure buffer alignment.
2011-12-13 Vladimir Serbinenko <phcoder@gmail.com> 2011-12-13 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/ext2.c (grub_ext4_find_leaf): MAke buf as pointer to * grub-core/fs/ext2.c (grub_ext4_find_leaf): MAke buf as pointer to

View file

@ -208,6 +208,7 @@ struct grub_nilfs2_btree_node
grub_uint8_t bn_level; grub_uint8_t bn_level;
grub_uint16_t bn_nchildren; grub_uint16_t bn_nchildren;
grub_uint32_t bn_pad; grub_uint32_t bn_pad;
grub_uint64_t keys[0];
}; };
struct grub_nilfs2_palloc_group_desc struct grub_nilfs2_palloc_group_desc
@ -399,9 +400,9 @@ grub_nilfs2_btree_get_level (struct grub_nilfs2_btree_node *node)
static inline grub_uint64_t * static inline grub_uint64_t *
grub_nilfs2_btree_node_dkeys (struct grub_nilfs2_btree_node *node) grub_nilfs2_btree_node_dkeys (struct grub_nilfs2_btree_node *node)
{ {
return (grub_uint64_t *) ((char *) (node + 1) + return (node->keys +
((node->bn_flags & NILFS_BTREE_NODE_ROOT) ? ((node->bn_flags & NILFS_BTREE_NODE_ROOT) ?
0 : NILFS_BTREE_NODE_EXTRA_PAD_SIZE)); 0 : (NILFS_BTREE_NODE_EXTRA_PAD_SIZE / sizeof (grub_uint64_t))));
} }
static inline grub_uint64_t static inline grub_uint64_t
@ -502,7 +503,7 @@ grub_nilfs2_btree_lookup (struct grub_nilfs2_data *data,
grub_uint64_t key, int need_translate) grub_uint64_t key, int need_translate)
{ {
struct grub_nilfs2_btree_node *node; struct grub_nilfs2_btree_node *node;
unsigned char block[NILFS2_BLOCK_SIZE (data)]; GRUB_PROPERLY_ALIGNED_ARRAY (block, NILFS2_BLOCK_SIZE (data));
grub_uint64_t ptr; grub_uint64_t ptr;
int level, found, index; int level, found, index;