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

From: Gerrit Huizenga
Date: Thu Jun 23 2005 - 02:36:06 EST


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@xxxxxxxxxx>
Signed-off-by: Gerrit Huizenga <gh@xxxxxxxxxx>

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

--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/