Skip to contentSkip to conversation

Trivial patch2:changing const char foo* to const char foo[] in

KJ [email protected] 2 participants 2 messages Apr 16, 2007

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Files modified
fs/binfmt_misc.c
fs/ntfs/attrib.c
fs/ntfs/inode.c
fs/ntfs/mft.c
fs/ntfs/super.c

As suggested by Jeff Garzik,
----

Quoted 6 lines

The string form [const] char *foo = "blah";
creates two variables in the final assembly output, a static string, and
a char pointer to the static string. The alternate string form [const] char foo[] = "blah"; is better because it declares a single variable.

------

Cleaned up for the new modifications.

---

fs/binfmt_misc.c +1 -1
index e6f5799..b9ef210 100644
@@ -445,7 +445,7 @@ static void entry_status(Node *e, char *page)
 {
 	char *dp;
 	char *status = "disabled";
-	const char * flags = "flags: ";
+	const char  flags[] = "flags: ";
 
 	if (test_bit(Enabled, &e->flags))
 		status = "enabled";
fs/ntfs/attrib.c +0 -0
index 7659cc1..6f9345d 100644
@@ -869,7 +869,7 @@ static int ntfs_external_attr_find(const ATTR_TYPE

type,
ntfschar *al_name;
u32 al_name_len;
int err = 0;
- static const char *es = " Unmount and run chkdsk.";
+ static const char es[] = " Unmount and run chkdsk.";

ni = ctx->ntfs_ino;
base_ni = ctx->base_ntfs_ino;

fs/ntfs/inode.c +1 -1
index f8bf8da..f580025 100644
@@ -1871,7 +1871,7 @@ int ntfs_read_inode_mount(struct inode *vi)
 	} else /* if (!err) */ {
 		ATTR_LIST_ENTRY *al_entry, *next_al_entry;
 		u8 *al_end;
-		static const char *es = "  Not allowed.  $MFT is corrupt.  "
+		static const char es[] = "  Not allowed.  $MFT is corrupt.  "
 				"You should run chkdsk.";
 
 		ntfs_debug("Attribute list attribute found in $MFT.");
@@ -2333,7 +2333,7 @@ int ntfs_show_options(struct seq_file *sf, struct

vfsmount *mnt)

#ifdef NTFS_RW

-static const char *es = " Leaving inconsistent metadata. Unmount and run "
+static const char es[] = " Leaving inconsistent metadata. Unmount and run "
"chkdsk.";

/**
@@ -2369,7 +2369,7 @@ int ntfs_truncate(struct inode *vi)
ntfs_attr_search_ctx *ctx;
MFT_RECORD *m;
ATTR_RECORD *a;
- const char *te = " Leaving file length out of sync with i_size.";
+ const char te[] = " Leaving file length out of sync with i_size.";
int err, mp_size, size_change, alloc_change; u32 attr_len;

fs/ntfs/mft.c +1 -1
index 2ad5c8b..a560bb0 100644
@@ -409,7 +409,7 @@ void __mark_mft_record_dirty(ntfs_inode *ni)
 	__mark_inode_dirty(VFS_I(base_ni), I_DIRTY_SYNC | I_DIRTY_DATASYNC);
 }
 
-static const char *ntfs_please_email = "Please email "
+static const char ntfs_please_email[] = "Please email "
 		"[email protected] and say that you saw "
 		"this message.  Thank you.";
 
@@ -1106,7 +1106,7 @@ bool ntfs_may_write_mft_record(ntfs_volume *vol,

const unsigned long mft_no,
return true;
}

-static const char *es = " Leaving inconsistent metadata. Unmount and run "
+static const char es[] = " Leaving inconsistent metadata. Unmount and run "
"chkdsk.";

/**

fs/ntfs/super.c +0 -0
index 1594c90..1fe6ddd 100644
@@ -647,7 +647,7 @@ not_ntfs:
 static struct buffer_head *read_ntfs_boot_sector(struct super_block

*sb,
const int silent)
{
- const char *read_err_str = "Unable to read %s boot sector.";
+ const char read_err_str[] = "Unable to read %s boot sector.";
struct buffer_head *bh_primary, *bh_backup; sector_t nr_blocks = NTFS_SB(sb)->nr_blocks;

@@ -1756,9 +1756,9 @@ static bool load_system_files(ntfs_volume *vol)
#ifdef NTFS_RW
/* Get mft mirror inode compare the contents of $MFT and $MFTMirr. */ if (!load_and_init_mft_mirror(vol) || !check_mft_mirror(vol)) {
- static const char *es1 = "Failed to load $MFTMirr";
- static const char *es2 = "$MFTMirr does not match $MFT";
- static const char *es3 = ". Run ntfsfix and/or chkdsk.";
+ static const char es1[] = "Failed to load $MFTMirr";
+ static const char es2[] = "$MFTMirr does not match $MFT";
+ static const char es3[] = ". Run ntfsfix and/or chkdsk.";

/* If a read-write mount, convert it to a read-only mount. */ if (!(sb->s_flags & MS_RDONLY)) {
@@ -1880,11 +1880,11 @@ get_ctx_vol_failed:
#ifdef NTFS_RW
/* Make sure that no unsupported volume flags are set. */ if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) {
- static const char *es1a = "Volume is dirty";
- static const char *es1b = "Volume has been modified by chkdsk";
- static const char *es1c = "Volume has unsupported flags set";
- static const char *es2a = ". Run chkdsk and mount in Windows.";
- static const char *es2b = ". Mount in Windows.";
+ static const char es1a[] = "Volume is dirty";
+ static const char es1b[] = "Volume has been modified by chkdsk";
+ static const char es1c[] = "Volume has unsupported flags set";
+ static const char es2a[] = ". Run chkdsk and mount in Windows.";
+ static const char es2b[] = ". Mount in Windows.";
const char *es1, *es2;

es2 = es2a;
@@ -1926,9 +1926,9 @@ get_ctx_vol_failed:
rp = NULL;
if (!load_and_check_logfile(vol, &rp) ||
!ntfs_is_logfile_clean(vol->logfile_ino, rp)) {
- static const char *es1a = "Failed to load $LogFile";
- static const char *es1b = "$LogFile is not clean";
- static const char *es2 = ". Mount in Windows.";
+ static const char es1a[] = "Failed to load $LogFile";
+ static const char es1b[] = "$LogFile is not clean";
+ static const char es2[] = ". Mount in Windows.";
const char *es1;

es1 = !vol->logfile_ino ? es1a : es1b;
@@ -1974,10 +1974,10 @@ get_ctx_vol_failed:
*/
err = check_windows_hibernation_status(vol); if (unlikely(err)) {
- static const char *es1a = "Failed to determine if Windows is "
+ static const char es1a[] = "Failed to determine if Windows is "
"hibernated";
- static const char *es1b = "Windows is hibernated";
- static const char *es2 = ". Run chkdsk.";
+ static const char es1b[] = "Windows is hibernated";
+ static const char es2[] = ". Run chkdsk.";
const char *es1;

es1 = err < 0 ? es1a : es1b;
@@ -2049,8 +2049,8 @@ get_ctx_vol_failed:
/* If (still) a read-write mount, empty the logfile. */ if (!(sb->s_flags & MS_RDONLY) &&
!ntfs_empty_logfile(vol->logfile_ino)) {
- static const char *es1 = "Failed to empty $LogFile";
- static const char *es2 = ". Mount in Windows.";
+ static const char es1[] = "Failed to empty $LogFile";
+ static const char es2[] = ". Mount in Windows.";

/* Convert to a read-only mount. */
if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO |
@@ -2089,8 +2089,8 @@ get_ctx_vol_failed:
#ifdef NTFS_RW
/* Find the quota file, load it if present, and set it up. */ if (!load_and_init_quota(vol)) {
- static const char *es1 = "Failed to load $Quota";
- static const char *es2 = ". Run chkdsk.";
+ static const char es1[] = "Failed to load $Quota";
+ static const char es2[] = ". Run chkdsk.";

/* If a read-write mount, convert it to a read-only mount. */ if (!(sb->s_flags & MS_RDONLY)) {
@@ -2113,8 +2113,8 @@ get_ctx_vol_failed:
/* If (still) a read-write mount, mark the quotas out of date. */ if (!(sb->s_flags & MS_RDONLY) &&
!ntfs_mark_quotas_out_of_date(vol)) {
- static const char *es1 = "Failed to mark quotas out of date";
- static const char *es2 = ". Run chkdsk.";
+ static const char es1[] = "Failed to mark quotas out of date";
+ static const char es2[] = ". Run chkdsk.";

/* Convert to a read-only mount. */ if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO |
@@ -2133,8 +2133,8 @@ get_ctx_vol_failed:
* it, and set it up.
*/
if (!load_and_init_usnjrnl(vol)) {
- static const char *es1 = "Failed to load $UsnJrnl";
- static const char *es2 = ". Run chkdsk.";
+ static const char es1[] = "Failed to load $UsnJrnl";
+ static const char es2[] = ". Run chkdsk.";

/* If a read-write mount, convert it to a read-only mount. */ if (!(sb->s_flags & MS_RDONLY)) {
@@ -2156,9 +2156,9 @@ get_ctx_vol_failed:
}
/* If (still) a read-write mount, stamp the transaction log. */ if (!(sb->s_flags & MS_RDONLY) && !ntfs_stamp_usnjrnl(vol)) {
- static const char *es1 = "Failed to stamp transaction log "
+ static const char []es1 = "Failed to stamp transaction log "
"($UsnJrnl)";
- static const char *es2 = ". Run chkdsk.";
+ static const char []es2 = ". Run chkdsk.";

/* Convert to a read-only mount. */
if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO |
@@ -2389,13 +2389,13 @@ static void ntfs_put_super(struct super_block *sb)
mutex_unlock(&vol->mft_ino->i_mutex); write_inode_now(vol->mft_ino, 1);
if (!list_empty(&sb->s_dirty)) {
- static const char *_s1 = "inodes";
- static const char *_s2 = "";
+ static const char _s1[] = "inodes";
+ static const char _s2[] = "";
s1 = _s1;
s2 = _s2;
} else {
- static const char *_s1 = "mft pages";
- static const char *_s2 = "They have been thrown "
+ static const char _s1[] = "mft pages";
+ static const char _s2[] = "They have been thrown "
"away. ";
s1 = _s1;
s2 = _s2;

Signature · 2 lines
surya.
16/04/2007

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#1 lore raw

Re: [KJ] Trivial patch2:changing const char foo* to const char

2007/4/16, [email protected] <[email protected]>:
your patch is corrupted - try to apply it

fs/binfmt_misc.c static void entry_status(Node *e, char *page) · line 451

Quoted 13 lines
fs/binfmt_misc.c +1 -1
index e6f5799..b9ef210 100644
@@ -445,7 +445,7 @@ static void entry_status(Node *e, char *page)
 {
 	char *dp;
 	char *status = "disabled";
-	const char * flags = "flags: ";
+	const char  flags[] = "flags: ";
 
 	if (test_bit(Enabled, &e->flags))
 		status = "enabled";

it creates more code (on every call, this string will be copied) mark this variable as static

fs/binfmt_misc.c int ntfs_truncate(struct inode *vi) · line 2375

Quoted 9 lines
fs/binfmt_misc.c +1 -1
@@ -2369,7 +2369,7 @@ int ntfs_truncate(struct inode *vi)
 	ntfs_attr_search_ctx *ctx;
 	MFT_RECORD *m;
 	ATTR_RECORD *a;
-	const char *te = "  Leaving file length out of sync with i_size.";
+	const char te[] = "  Leaving file length out of sync with i_size.";
 	int err, mp_size, size_change, alloc_change;
 	u32 attr_len;
 

again

Quoted 6 lines
fs/ntfs/super.c +0 -0
index 1594c90..1fe6ddd 100644

fs/ntfs/super.c not_ntfs: · line 653

Quoted 8 lines
fs/ntfs/super.c +1 -1
@@ -647,7 +647,7 @@ not_ntfs:
 static struct buffer_head *read_ntfs_boot_sector(struct super_block
 *sb,
                const int silent)
 {
-       const char *read_err_str = "Unable to read %s boot sector.";
+       const char read_err_str[] = "Unable to read %s boot sector.";
        struct buffer_head *bh_primary, *bh_backup;
        sector_t nr_blocks = NTFS_SB(sb)->nr_blocks;

again

fs/ntfs/super.c get_ctx_vol_failed: · line 2164

Quoted 12 lines
fs/ntfs/super.c +2 -2
@@ -2156,9 +2156,9 @@ get_ctx_vol_failed:
        }
        /* If (still) a read-write mount, stamp the transaction log. */
        if (!(sb->s_flags & MS_RDONLY) && !ntfs_stamp_usnjrnl(vol)) {
-               static const char *es1 = "Failed to stamp transaction log "
+               static const char []es1 = "Failed to stamp transaction log "
                                "($UsnJrnl)";
-               static const char *es2 = ".  Run chkdsk.";
+               static const char []es2 = ".  Run chkdsk.";
 
                /* Convert to a read-only mount. */
                if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO |

doesn't compile
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors