public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NTFS: Change string pointers to string constants.
@ 2009-12-03  2:53 John Daiker
  2009-12-08  0:57 ` Anton Altaparmakov
  0 siblings, 1 reply; 6+ messages in thread
From: John Daiker @ 2009-12-03  2:53 UTC (permalink / raw)
  To: kernel-janitors, linux-ntfs-dev; +Cc: aia21, linux-kernel, John Daiker

As per the KernelJanitors ToDo list, change the following:
char *foo = "bar";   =>   char foo[] = "bar";

Signed-off-by: John Daiker <daikerjohn@gmail.com>
---
 fs/ntfs/attrib.c |    2 +-
 fs/ntfs/inode.c  |    6 ++--
 fs/ntfs/mft.c    |    4 +-
 fs/ntfs/super.c  |   60 +++++++++++++++++++++++++++---------------------------
 4 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index 50d3b0c..a8aaa48 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -866,7 +866,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;
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 9938034..e22aa8c 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -1867,7 +1867,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.");
@@ -2328,7 +2328,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.";
 
 /**
@@ -2364,7 +2364,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;
 
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index 1caa0ef..261a107 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -408,7 +408,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 "
 		"linux-ntfs-dev@lists.sourceforge.net and say that you saw "
 		"this message.  Thank you.";
 
@@ -1105,7 +1105,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.";
 
 /**
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 80b0477..e6dcd71 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -461,7 +461,7 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
 	 * have occured.
 	 */
 	if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
-		static const char *es = ".  Cannot remount read-write.";
+		static const char es[] = ".  Cannot remount read-write.";
 
 		/* Remounting read-write. */
 		if (NVolErrors(vol)) {
@@ -659,7 +659,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;
 
@@ -1768,9 +1768,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)) {
@@ -1892,11 +1892,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;
@@ -1938,9 +1938,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;
@@ -1986,10 +1986,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;
@@ -2014,9 +2014,9 @@ get_ctx_vol_failed:
 	/* If (still) a read-write mount, mark the volume dirty. */
 	if (!(sb->s_flags & MS_RDONLY) &&
 			ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) {
-		static const char *es1 = "Failed to set dirty bit in volume "
+		static const char es1[] = "Failed to set dirty bit in volume "
 				"information flags";
-		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 |
@@ -2042,8 +2042,8 @@ get_ctx_vol_failed:
 	 */
 	if (!(sb->s_flags & MS_RDONLY) && (vol->major_ver > 1) &&
 			ntfs_set_volume_flags(vol, VOLUME_MOUNTED_ON_NT4)) {
-		static const char *es1 = "Failed to set NT4 compatibility flag";
-		static const char *es2 = ".  Run chkdsk.";
+		static const char es1[] = "Failed to set NT4 compatibility flag";
+		static const char es2[] = ".  Run chkdsk.";
 
 		/* Convert to a read-only mount. */
 		if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO |
@@ -2061,8 +2061,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 |
@@ -2101,8 +2101,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)) {
@@ -2125,8 +2125,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 |
@@ -2145,8 +2145,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)) {
@@ -2168,9 +2168,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 |
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] NTFS: Change string pointers to string constants.
  2009-12-03  2:53 [PATCH] NTFS: Change string pointers to string constants John Daiker
@ 2009-12-08  0:57 ` Anton Altaparmakov
  2009-12-08  1:47   ` Joe Perches
  0 siblings, 1 reply; 6+ messages in thread
From: Anton Altaparmakov @ 2009-12-08  0:57 UTC (permalink / raw)
  To: John Daiker; +Cc: kernel-janitors, linux-ntfs-dev, aia21, linux-kernel

Hi,

On 3 Dec 2009, at 02:53, John Daiker wrote:
> As per the KernelJanitors ToDo list, change the following:
> char *foo = "bar";   =>   char foo[] = "bar";

Can you please explain the rational for making this change?  Visually it uses an extra character so I prefer the *string notation rather than the string[] notation.  If there is some actual functional difference then I would like to know what the difference is.

If it is explained in the ToDo list you mention, feel free to post a link to that instead of explaining.

Thanks a lot in advance!

Best regards,

	Anton

> Signed-off-by: John Daiker <daikerjohn@gmail.com>
> ---
> fs/ntfs/attrib.c |    2 +-
> fs/ntfs/inode.c  |    6 ++--
> fs/ntfs/mft.c    |    4 +-
> fs/ntfs/super.c  |   60 +++++++++++++++++++++++++++---------------------------
> 4 files changed, 36 insertions(+), 36 deletions(-)
> 
> diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
> index 50d3b0c..a8aaa48 100644
> --- a/fs/ntfs/attrib.c
> +++ b/fs/ntfs/attrib.c
> @@ -866,7 +866,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;
> diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
> index 9938034..e22aa8c 100644
> --- a/fs/ntfs/inode.c
> +++ b/fs/ntfs/inode.c
> @@ -1867,7 +1867,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.");
> @@ -2328,7 +2328,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.";
> 
> /**
> @@ -2364,7 +2364,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;
> 
> diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
> index 1caa0ef..261a107 100644
> --- a/fs/ntfs/mft.c
> +++ b/fs/ntfs/mft.c
> @@ -408,7 +408,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 "
> 		"linux-ntfs-dev@lists.sourceforge.net and say that you saw "
> 		"this message.  Thank you.";
> 
> @@ -1105,7 +1105,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.";
> 
> /**
> diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> index 80b0477..e6dcd71 100644
> --- a/fs/ntfs/super.c
> +++ b/fs/ntfs/super.c
> @@ -461,7 +461,7 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
> 	 * have occured.
> 	 */
> 	if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
> -		static const char *es = ".  Cannot remount read-write.";
> +		static const char es[] = ".  Cannot remount read-write.";
> 
> 		/* Remounting read-write. */
> 		if (NVolErrors(vol)) {
> @@ -659,7 +659,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;
> 
> @@ -1768,9 +1768,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)) {
> @@ -1892,11 +1892,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;
> @@ -1938,9 +1938,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;
> @@ -1986,10 +1986,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;
> @@ -2014,9 +2014,9 @@ get_ctx_vol_failed:
> 	/* If (still) a read-write mount, mark the volume dirty. */
> 	if (!(sb->s_flags & MS_RDONLY) &&
> 			ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) {
> -		static const char *es1 = "Failed to set dirty bit in volume "
> +		static const char es1[] = "Failed to set dirty bit in volume "
> 				"information flags";
> -		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 |
> @@ -2042,8 +2042,8 @@ get_ctx_vol_failed:
> 	 */
> 	if (!(sb->s_flags & MS_RDONLY) && (vol->major_ver > 1) &&
> 			ntfs_set_volume_flags(vol, VOLUME_MOUNTED_ON_NT4)) {
> -		static const char *es1 = "Failed to set NT4 compatibility flag";
> -		static const char *es2 = ".  Run chkdsk.";
> +		static const char es1[] = "Failed to set NT4 compatibility flag";
> +		static const char es2[] = ".  Run chkdsk.";
> 
> 		/* Convert to a read-only mount. */
> 		if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO |
> @@ -2061,8 +2061,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 |
> @@ -2101,8 +2101,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)) {
> @@ -2125,8 +2125,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 |
> @@ -2145,8 +2145,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)) {
> @@ -2168,9 +2168,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 |
-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer, http://www.linux-ntfs.org/


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] NTFS: Change string pointers to string constants.
  2009-12-08  0:57 ` Anton Altaparmakov
@ 2009-12-08  1:47   ` Joe Perches
  2009-12-08 19:16     ` John Daiker
  2009-12-09 14:59     ` Marcin Slusarz
  0 siblings, 2 replies; 6+ messages in thread
From: Joe Perches @ 2009-12-08  1:47 UTC (permalink / raw)
  To: Anton Altaparmakov
  Cc: John Daiker, kernel-janitors, aia21, linux-ntfs-dev, LKML

On Tue, 2009-12-08 at 00:57 +0000, Anton Altaparmakov wrote:
> Can you please explain the rational for making this change?

Perhaps it's not worth much, but it saves a pointer reference.

$ cat pointer.c
#include <string.h>
#include <stdio.h>

int main (int argc, char** argv)
{
	static const char *foo = "abcdefg";
	printf("%s\n", foo);
	return 0;
}

$ gcc -c pointer.c
$ size pointer.o
   text	   data	    bss	    dec	    hex	filename
     37	      4	      0	     41	     29	pointer.o

$ cat reference.c
#include <string.h>
#include <stdio.h>

int main (int argc, char** argv)
{
static const char foo[] = "abcdefg";
printf("%s\n", foo);
return 0;
}

$ gcc -c reference.c
$ size reference.o
   text    data     bss     dec     hex filename
     36       0       0      36      24 reference.o




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] NTFS: Change string pointers to string constants.
  2009-12-08  1:47   ` Joe Perches
@ 2009-12-08 19:16     ` John Daiker
  2009-12-09 14:59     ` Marcin Slusarz
  1 sibling, 0 replies; 6+ messages in thread
From: John Daiker @ 2009-12-08 19:16 UTC (permalink / raw)
  To: Anton Altaparmakov
  Cc: Joe Perches, kernel-janitors, aia21, linux-ntfs-dev, LKML

On 12/07/2009 05:47 PM, Joe Perches wrote:
> On Tue, 2009-12-08 at 00:57 +0000, Anton Altaparmakov wrote:
>> Can you please explain the rational for making this change?
>
> Perhaps it's not worth much, but it saves a pointer reference.
>
> $ cat pointer.c
> #include<string.h>
> #include<stdio.h>
>
> int main (int argc, char** argv)
> {
> 	static const char *foo = "abcdefg";
> 	printf("%s\n", foo);
> 	return 0;
> }
>
> $ gcc -c pointer.c
> $ size pointer.o
>     text	   data	    bss	    dec	    hex	filename
>       37	      4	      0	     41	     29	pointer.o
>
> $ cat reference.c
> #include<string.h>
> #include<stdio.h>
>
> int main (int argc, char** argv)
> {
> static const char foo[] = "abcdefg";
> printf("%s\n", foo);
> return 0;
> }
>
> $ gcc -c reference.c
> $ size reference.o
>     text    data     bss     dec     hex filename
>       36       0       0      36      24 reference.o
>
>
>

As Joe mentioned above (thanks Joe!) it saves a pointer reference.

It is also listed as a KernelJanitors ToDo item (about 2/3 of the way 
down the page).  Searching for 'From: Jeff Garzik' should find it.

John

[1] http://kernelnewbies.org/KernelJanitors/Todo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] NTFS: Change string pointers to string constants.
  2009-12-08  1:47   ` Joe Perches
  2009-12-08 19:16     ` John Daiker
@ 2009-12-09 14:59     ` Marcin Slusarz
  2009-12-09 15:07       ` walter harms
  1 sibling, 1 reply; 6+ messages in thread
From: Marcin Slusarz @ 2009-12-09 14:59 UTC (permalink / raw)
  To: Joe Perches
  Cc: Anton Altaparmakov, John Daiker, kernel-janitors, aia21,
	linux-ntfs-dev, LKML

On Mon, Dec 07, 2009 at 05:47:13PM -0800, Joe Perches wrote:
> On Tue, 2009-12-08 at 00:57 +0000, Anton Altaparmakov wrote:
> > Can you please explain the rational for making this change?
> 
> Perhaps it's not worth much, but it saves a pointer reference.
> 
> $ cat pointer.c
> #include <string.h>
> #include <stdio.h>
> 
> int main (int argc, char** argv)
> {
> 	static const char *foo = "abcdefg";
> 	printf("%s\n", foo);
> 	return 0;
> }
> 
> $ gcc -c pointer.c
> $ size pointer.o
>    text	   data	    bss	    dec	    hex	filename
>      37	      4	      0	     41	     29	pointer.o
> 
> $ cat reference.c
> #include <string.h>
> #include <stdio.h>
> 
> int main (int argc, char** argv)
> {
> static const char foo[] = "abcdefg";
> printf("%s\n", foo);
> return 0;
> }
> 
> $ gcc -c reference.c
> $ size reference.o
>    text    data     bss     dec     hex filename
>      36       0       0      36      24 reference.o

Yeah, for static variables it's better. But for automatic variables
it's worse, because it now has to do a copy at runtime.
And the patch changes both types.

$ size pointer.o reference.o
   text    data     bss     dec     hex filename
    101       8       0     109      6d pointer.o
     96       0       0      96      60 reference.o

$ size pointer-nonstatic.o reference-nonstatic.o
   text    data     bss     dec     hex filename
    106       0       0     106      6a pointer-nonstatic.o
    109       0       0     109      6d reference-nonstatic.o

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] NTFS: Change string pointers to string constants.
  2009-12-09 14:59     ` Marcin Slusarz
@ 2009-12-09 15:07       ` walter harms
  0 siblings, 0 replies; 6+ messages in thread
From: walter harms @ 2009-12-09 15:07 UTC (permalink / raw)
  To: Marcin Slusarz
  Cc: Joe Perches, Anton Altaparmakov, John Daiker, kernel-janitors,
	aia21, linux-ntfs-dev, LKML



Marcin Slusarz schrieb:
> On Mon, Dec 07, 2009 at 05:47:13PM -0800, Joe Perches wrote:
>> On Tue, 2009-12-08 at 00:57 +0000, Anton Altaparmakov wrote:
>>> Can you please explain the rational for making this change?
>> Perhaps it's not worth much, but it saves a pointer reference.
>>
>> $ cat pointer.c
>> #include <string.h>
>> #include <stdio.h>
>>
>> int main (int argc, char** argv)
>> {
>> 	static const char *foo = "abcdefg";
>> 	printf("%s\n", foo);
>> 	return 0;
>> }
>>
>> $ gcc -c pointer.c
>> $ size pointer.o
>>    text	   data	    bss	    dec	    hex	filename
>>      37	      4	      0	     41	     29	pointer.o
>>
>> $ cat reference.c
>> #include <string.h>
>> #include <stdio.h>
>>
>> int main (int argc, char** argv)
>> {
>> static const char foo[] = "abcdefg";
>> printf("%s\n", foo);
>> return 0;
>> }
>>
>> $ gcc -c reference.c
>> $ size reference.o
>>    text    data     bss     dec     hex filename
>>      36       0       0      36      24 reference.o
> 
> Yeah, for static variables it's better. But for automatic variables
> it's worse, because it now has to do a copy at runtime.
> And the patch changes both types.
> 
> $ size pointer.o reference.o
>    text    data     bss     dec     hex filename
>     101       8       0     109      6d pointer.o
>      96       0       0      96      60 reference.o
> 
> $ size pointer-nonstatic.o reference-nonstatic.o
>    text    data     bss     dec     hex filename
>     106       0       0     106      6a pointer-nonstatic.o
>     109       0       0     109      6d reference-nonstatic.o
> --


nobody should spend to much time on this. gcc <what ever next version>
will have different results. It is better to spend time improving
the compiler and make it generate shorter/faster code.

just my 2 cents,
 wh

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-12-09 15:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-03  2:53 [PATCH] NTFS: Change string pointers to string constants John Daiker
2009-12-08  0:57 ` Anton Altaparmakov
2009-12-08  1:47   ` Joe Perches
2009-12-08 19:16     ` John Daiker
2009-12-09 14:59     ` Marcin Slusarz
2009-12-09 15:07       ` walter harms

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox