[patch 37/38] CKRM e18: Use sizeof instead of define for the array size in RBCE

Gerrit Huizenga
2005-06-23T07:26:59Z

[-- Attachment #1: use_sizeof_instead_of_define_for_the_array_size_in_rbce --]
[-- Type: text/plain, Size: 1545 bytes --]

While creating the config files for rbce, instead of using #define
use sizeof so that when the array size changes, things still work as
expected.

Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Gerrit Huizenga <gh@us.ibm.com>

Index: linux-2.6.12-ckrm1/kernel/ckrm/rbce/rbce_fs.c
===================================================================
--- linux-2.6.12-ckrm1.orig/kernel/ckrm/rbce/rbce_fs.c 2005-06-20 15:02:49.000000000 -0700
+++ linux-2.6.12-ckrm1/kernel/ckrm/rbce/rbce_fs.c 2005-06-20 16:01:57.000000000 -0700
@@ -273,8 +273,7 @@ rbce_symlink(struct inode *dir, struct d

/******************************* Config files ********************/

-#define RBCE_NR_CONFIG 5
-struct rcfs_magf rbce_config_files[RBCE_NR_CONFIG] = {
+struct rcfs_magf rbce_config_files[] = {
{
.name = CONFIG_CE_DIR,
.mode = RCFS_DEFAULT_DIR_MODE,
@@ -302,16 +301,17 @@ static struct dentry *ce_root_dentry;

int rbce_create_config(void)
{
- int rc;
+ int rc, nr;

+ nr = sizeof(rbce_config_files) / sizeof(struct rcfs_magf);
/* Make root dentry */
- rc = rcfs_mkroot(rbce_config_files, RBCE_NR_CONFIG, &ce_root_dentry);
+ rc = rcfs_mkroot(rbce_config_files, nr, &ce_root_dentry);
if ((!ce_root_dentry) || rc)
return rc;

/* Create config files */
if ((rc = rcfs_create_magic(ce_root_dentry, &rbce_config_files[1],
- RBCE_NR_CONFIG - 1))) {
+ nr - 1))) {
printk(KERN_ERR "Failed to create c/rbce config files."
" Deleting c/rbce root\n");
rcfs_rmroot(ce_root_dentry);

--