2005-01-03 17:22:35

by William Lee Irwin III

[permalink] [raw]
Subject: [0/8] patches vs. 2.6.10-mm1

This is a series of patches against 2.6.10-mm1. They are mostly warning
cleanups, starting with a compilefix.


-- wli


2005-01-03 17:29:29

by William Lee Irwin III

[permalink] [raw]
Subject: [2/8] kill quota_v2.c printk() of size_t warning

The printk() of a size_t is off, tripping a warning. This patch qualifies
the integer format with a 'z' to suppress the warning.

Signed-off-by: William Irwin <[email protected]>


Index: mm1-2.6.10/fs/quota_v2.c
===================================================================
--- mm1-2.6.10.orig/fs/quota_v2.c 2005-01-03 06:44:20.000000000 -0800
+++ mm1-2.6.10/fs/quota_v2.c 2005-01-03 07:51:53.000000000 -0800
@@ -396,7 +396,7 @@
/* dq_off is guarded by dqio_sem */
if (!dquot->dq_off)
if ((ret = dq_insert_tree(dquot)) < 0) {
- printk(KERN_ERR "VFS: Error %d occurred while creating quota.\n", ret);
+ printk(KERN_ERR "VFS: Error %zd occurred while creating quota.\n", ret);
return ret;
}
spin_lock(&dq_data_lock);

2005-01-03 17:30:32

by William Lee Irwin III

[permalink] [raw]
Subject: [3/8] kill gen_init_cpio.c printk() of size_t warning

The rest of gen_init_cpio.c seems to cast the result of strlen() to
handle this situation, so this patch follows suit while killing off
size_t -related printk() warnings.

Signed-off-by: William Irwin <[email protected]>

Index: mm1-2.6.10/usr/gen_init_cpio.c
===================================================================
--- mm1-2.6.10.orig/usr/gen_init_cpio.c 2005-01-03 06:45:53.000000000 -0800
+++ mm1-2.6.10/usr/gen_init_cpio.c 2005-01-03 08:11:18.000000000 -0800
@@ -86,7 +86,7 @@
0, /* minor */
0, /* rmajor */
0, /* rminor */
- (unsigned)strlen(name) + 1, /* namesize */
+ (unsigned)strlen(name)+1, /* namesize */
0); /* chksum */
push_hdr(s);
push_rest(name);
@@ -112,7 +112,7 @@
(long) gid, /* gid */
1, /* nlink */
(long) mtime, /* mtime */
- strlen(target) + 1, /* filesize */
+ (unsigned)strlen(target)+1, /* filesize */
3, /* major */
1, /* minor */
0, /* rmajor */

2005-01-03 17:37:08

by William Lee Irwin III

[permalink] [raw]
Subject: [4/8] fix arch/x86_64/ia32/syscall32.c misdeclared pud variable

This __map_syscall32() gets an assignment from incompatible pointer type
warning; the following patch kills it by declaring the pud variable as a
pud_t as is necessary.

Signed-off-by: William Irwin <[email protected]>

Index: mm1-2.6.10/arch/x86_64/ia32/syscall32.c
===================================================================
--- mm1-2.6.10.orig/arch/x86_64/ia32/syscall32.c 2005-01-03 06:44:20.000000000 -0800
+++ mm1-2.6.10/arch/x86_64/ia32/syscall32.c 2005-01-03 07:56:06.000000000 -0800
@@ -41,7 +41,7 @@
int __map_syscall32(struct mm_struct *mm, unsigned long address)
{
pgd_t *pgd;
- pgd_t *pud;
+ pud_t *pud;
pte_t *pte;
pmd_t *pmd;
int err = -ENOMEM;

2005-01-03 17:40:50

by William Lee Irwin III

[permalink] [raw]
Subject: [6/8] make IRDA string tables conditional on CONFIG_IRDA_DEBUG

There are some string tables only used for debugging printk()'s in IRDA
that trip warnings when CONFIG_IRDA_DEBUG is not set.

This patch makes them conditional on CONFIG_IRDA_DEBUG to silence warnings.

Signed-off-by: William Irwin <[email protected]>

Index: mm1-2.6.10/net/irda/ircomm/ircomm_event.c
===================================================================
--- mm1-2.6.10.orig/net/irda/ircomm/ircomm_event.c 2005-01-03 06:44:20.000000000 -0800
+++ mm1-2.6.10/net/irda/ircomm/ircomm_event.c 2005-01-03 08:19:38.000000000 -0800
@@ -57,6 +57,7 @@
"IRCOMM_CONN",
};

+#ifdef CONFIG_IRDA_DEBUG
static char *ircomm_event[] = {
"IRCOMM_CONNECT_REQUEST",
"IRCOMM_CONNECT_RESPONSE",
@@ -75,6 +76,7 @@
"IRCOMM_CONTROL_REQUEST",
"IRCOMM_CONTROL_INDICATION",
};
+#endif /* CONFIG_IRDA_DEBUG */

static int (*state[])(struct ircomm_cb *self, IRCOMM_EVENT event,
struct sk_buff *skb, struct ircomm_info *info) =
Index: mm1-2.6.10/net/irda/ircomm/ircomm_tty_attach.c
===================================================================
--- mm1-2.6.10.orig/net/irda/ircomm/ircomm_tty_attach.c 2005-01-03 06:44:20.000000000 -0800
+++ mm1-2.6.10/net/irda/ircomm/ircomm_tty_attach.c 2005-01-03 08:18:48.000000000 -0800
@@ -91,6 +91,7 @@
"*** ERROR *** ",
};

+#ifdef CONFIG_IRDA_DEBUG
static char *ircomm_tty_event[] = {
"IRCOMM_TTY_ATTACH_CABLE",
"IRCOMM_TTY_DETACH_CABLE",
@@ -107,6 +108,7 @@
"IRCOMM_TTY_GOT_LSAPSEL",
"*** ERROR ****",
};
+#endif /* CONFIG_IRDA_DEBUG */

static int (*state[])(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct ircomm_tty_info *info) =

2005-01-03 17:49:25

by William Lee Irwin III

[permalink] [raw]
Subject: [4/8] fix arch/x86_64/ia32/syscall32.c misdeclared pud variable

pud needs to be declared as a pud_t in order to avoid an assignment
from incompatible pointer type warning or two; this patch makes it so.

Signed-off-by: William Irwin <[email protected]>

Index: mm1-2.6.10/arch/x86_64/ia32/syscall32.c
===================================================================
--- mm1-2.6.10.orig/arch/x86_64/ia32/syscall32.c 2005-01-03 06:44:20.000000000 -0800
+++ mm1-2.6.10/arch/x86_64/ia32/syscall32.c 2005-01-03 07:56:06.000000000 -0800
@@ -41,7 +41,7 @@
int __map_syscall32(struct mm_struct *mm, unsigned long address)
{
pgd_t *pgd;
- pgd_t *pud;
+ pud_t *pud;
pte_t *pte;
pmd_t *pmd;
int err = -ENOMEM;

2005-01-03 17:52:25

by William Lee Irwin III

[permalink] [raw]
Subject: [7/8] fix unresolved MTD symbols in scx200_docflash.c

This driver is using some private #ifdef to try to control the use of
partitions and calling functions that get compiled out of the kernel
if it's set (which it is by default). This results in unresolved module
symbols, which are bad.

This patch synchronizes the conditional compilation of partition
management in the driver with the global config option for MTD
partition management and thereby fixes the unresolved symbol problem.

Signed-off-by: William Irwin <[email protected]>

Index: mm1-2.6.10/drivers/mtd/maps/scx200_docflash.c
===================================================================
--- mm1-2.6.10.orig/drivers/mtd/maps/scx200_docflash.c 2005-01-03 06:46:06.000000000 -0800
+++ mm1-2.6.10/drivers/mtd/maps/scx200_docflash.c 2005-01-03 08:25:39.000000000 -0800
@@ -26,9 +26,6 @@
MODULE_DESCRIPTION("NatSemi SCx200 DOCCS Flash Driver");
MODULE_LICENSE("GPL");

-/* Set this to one if you want to partition the flash */
-#define PARTITION 1
-
static int probe = 0; /* Don't autoprobe */
static unsigned size = 0x1000000; /* 16 MiB the whole ISA address space */
static unsigned width = 8; /* Default to 8 bits wide */
@@ -50,7 +47,7 @@

static struct mtd_info *mymtd;

-#if PARTITION
+#ifdef CONFIG_MTD_PARTITIONS
static struct mtd_partition partition_info[] = {
{
.name = "DOCCS Boot kernel",
@@ -200,7 +197,7 @@

mymtd->owner = THIS_MODULE;

-#if PARTITION
+#ifdef CONFIG_MTD_PARTITIONS
partition_info[3].offset = mymtd->size-partition_info[3].size;
partition_info[2].size = partition_info[3].offset-partition_info[2].offset;
add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);
@@ -213,7 +210,7 @@
static void __exit cleanup_scx200_docflash(void)
{
if (mymtd) {
-#if PARTITION
+#ifdef CONFIG_MTD_PARTITIONS
del_mtd_partitions(mymtd);
#else
del_mtd_device(mymtd);

2005-01-03 17:52:25

by William Lee Irwin III

[permalink] [raw]
Subject: [5/8] silence numerous size_t warnings in drivers/acpi/processor_idle.c

Multiple format -related warnings arise from size_t issues. This
patch peppers the seq_printf()'s with 'z' qualifiers and casts to
silence them all.

Signed-off-by: Wililam Irwin <[email protected]>

Index: mm1-2.6.10/drivers/acpi/processor_idle.c
===================================================================
--- mm1-2.6.10.orig/drivers/acpi/processor_idle.c 2005-01-03 06:45:54.000000000 -0800
+++ mm1-2.6.10/drivers/acpi/processor_idle.c 2005-01-03 08:02:46.000000000 -0800
@@ -838,12 +838,12 @@
if (!pr)
goto end;

- seq_printf(seq, "active state: C%d\n"
+ seq_printf(seq, "active state: C%zd\n"
"max_cstate: C%d\n"
"bus master activity: %08x\n",
pr->power.state ? pr->power.state - pr->power.states : 0,
max_cstate,
- pr->power.bm_activity);
+ (unsigned)pr->power.bm_activity);

seq_puts(seq, "states:\n");

@@ -872,14 +872,14 @@
}

if (pr->power.states[i].promotion.state)
- seq_printf(seq, "promotion[C%d] ",
+ seq_printf(seq, "promotion[C%zd] ",
(pr->power.states[i].promotion.state -
pr->power.states));
else
seq_puts(seq, "promotion[--] ");

if (pr->power.states[i].demotion.state)
- seq_printf(seq, "demotion[C%d] ",
+ seq_printf(seq, "demotion[C%zd] ",
(pr->power.states[i].demotion.state -
pr->power.states));
else

2005-01-03 18:01:04

by Jeff Garzik

[permalink] [raw]
Subject: Re: [3/8] kill gen_init_cpio.c printk() of size_t warning

William Lee Irwin III wrote:
> The rest of gen_init_cpio.c seems to cast the result of strlen() to
> handle this situation, so this patch follows suit while killing off
> size_t -related printk() warnings.
>
> Signed-off-by: William Irwin <[email protected]>
>
> Index: mm1-2.6.10/usr/gen_init_cpio.c
> ===================================================================
> --- mm1-2.6.10.orig/usr/gen_init_cpio.c 2005-01-03 06:45:53.000000000 -0800
> +++ mm1-2.6.10/usr/gen_init_cpio.c 2005-01-03 08:11:18.000000000 -0800
> @@ -86,7 +86,7 @@
> 0, /* minor */
> 0, /* rmajor */
> 0, /* rminor */
> - (unsigned)strlen(name) + 1, /* namesize */
> + (unsigned)strlen(name)+1, /* namesize */
> 0); /* chksum */
> push_hdr(s);
> push_rest(name);
> @@ -112,7 +112,7 @@
> (long) gid, /* gid */
> 1, /* nlink */
> (long) mtime, /* mtime */
> - strlen(target) + 1, /* filesize */
> + (unsigned)strlen(target)+1, /* filesize */

This removes whitespace in the process, violating the file's chosen
style (and typical lkml style).

Jeff



2005-01-03 18:04:56

by linux-os

[permalink] [raw]
Subject: Re: [3/8] kill gen_init_cpio.c printk() of size_t warning

On Mon, 3 Jan 2005, William Lee Irwin III wrote:

> The rest of gen_init_cpio.c seems to cast the result of strlen() to
> handle this situation, so this patch follows suit while killing off
> size_t -related printk() warnings.
>
> Signed-off-by: William Irwin <[email protected]>
>
> Index: mm1-2.6.10/usr/gen_init_cpio.c
> ===================================================================
> --- mm1-2.6.10.orig/usr/gen_init_cpio.c 2005-01-03 06:45:53.000000000 -0800
> +++ mm1-2.6.10/usr/gen_init_cpio.c 2005-01-03 08:11:18.000000000 -0800
> @@ -86,7 +86,7 @@
> 0, /* minor */
> 0, /* rmajor */
> 0, /* rminor */
> - (unsigned)strlen(name) + 1, /* namesize */
> + (unsigned)strlen(name)+1, /* namesize */
> 0); /* chksum */
> push_hdr(s);
> push_rest(name);
> @@ -112,7 +112,7 @@
> (long) gid, /* gid */
> 1, /* nlink */
> (long) mtime, /* mtime */
> - strlen(target) + 1, /* filesize */
> + (unsigned)strlen(target)+1, /* filesize */
> 3, /* major */
> 1, /* minor */
> 0, /* rmajor */
> -

The problem is that '1' is an int, not an unsigned int.
So, the correct fix is:

strlen(target) + 1U;

Cheers,
Dick Johnson
Penguin : Linux version 2.6.9 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.

2005-01-03 18:17:36

by William Lee Irwin III

[permalink] [raw]
Subject: Re: [8/8] fix module_param() type mismatch in drivers/char/n_hdlc.c

On Mon, Jan 03, 2005 at 09:47:13AM -0800, William Lee Irwin III wrote:
> maxframe is a variable of type ssize_t; this patch repairs the warning
> arising from the type mismatch in the module_param() declaration.
> Signed-off-by: William Irwin <[email protected]>

I flubbed the testing cycle for that patch only. The following patch
should be applied instead.

Index: mm1-2.6.10/drivers/char/n_hdlc.c
===================================================================
--- mm1-2.6.10.orig/drivers/char/n_hdlc.c 2005-01-03 06:46:06.000000000 -0800
+++ mm1-2.6.10/drivers/char/n_hdlc.c 2005-01-03 09:38:17.000000000 -0800
@@ -177,7 +177,7 @@
static int debuglevel;

/* max frame size for memory allocations */
-static ssize_t maxframe = 4096;
+static int maxframe = 4096;

/* TTY callbacks */

@@ -672,7 +672,7 @@
if (debuglevel & DEBUG_LEVEL_INFO)
printk (KERN_WARNING
"n_hdlc_tty_write: truncating user packet "
- "from %lu to %Zd\n", (unsigned long) count,
+ "from %lu to %d\n", (unsigned long) count,
maxframe );
count = maxframe;
}

2005-01-03 18:17:34

by William Lee Irwin III

[permalink] [raw]
Subject: Re: [3/8] kill gen_init_cpio.c printk() of size_t warning

On Mon, Jan 03, 2005 at 12:59:55PM -0500, Jeff Garzik wrote:
> This removes whitespace in the process, violating the file's chosen
> style (and typical lkml style).

I have no personal interest in the whitespace involved. The following
amended patch is likely to avoid inconsistencies with the rest of the
file regarding whitespace.


-- wli


Index: mm1-2.6.10/usr/gen_init_cpio.c
===================================================================
--- mm1-2.6.10.orig/usr/gen_init_cpio.c 2005-01-03 06:45:53.000000000 -0800
+++ mm1-2.6.10/usr/gen_init_cpio.c 2005-01-03 09:42:18.000000000 -0800
@@ -112,7 +112,7 @@
(long) gid, /* gid */
1, /* nlink */
(long) mtime, /* mtime */
- strlen(target) + 1, /* filesize */
+ (unsigned)strlen(target) + 1,/* filesize */
3, /* major */
1, /* minor */
0, /* rmajor */

2005-01-03 18:26:54

by William Lee Irwin III

[permalink] [raw]
Subject: [8/8] fix module_param() type mismatch in drivers/char/n_hdlc.c

maxframe is a variable of type ssize_t; this patch repairs the warning
arising from the type mismatch in the module_param() declaration.

Signed-off-by: William Irwin <[email protected]>

Index: mm1-2.6.10/drivers/char/n_hdlc.c
===================================================================
--- mm1-2.6.10.orig/drivers/char/n_hdlc.c 2005-01-03 06:46:06.000000000 -0800
+++ mm1-2.6.10/drivers/char/n_hdlc.c 2005-01-03 08:35:57.000000000 -0800
@@ -976,5 +976,5 @@
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Paul Fulghum [email protected]");
module_param(debuglevel, int, 0);
-module_param(maxframe, int, 0);
+module_param(maxframe, ssize_t, 0);
MODULE_ALIAS_LDISC(N_HDLC);

2005-01-03 18:44:19

by linux-os

[permalink] [raw]
Subject: Re: [3/8] kill gen_init_cpio.c printk() of size_t warning

On Mon, 3 Jan 2005, William Lee Irwin III wrote:

> On Mon, Jan 03, 2005 at 12:59:55PM -0500, Jeff Garzik wrote:
>> This removes whitespace in the process, violating the file's chosen
>> style (and typical lkml style).
>
> I have no personal interest in the whitespace involved. The following
> amended patch is likely to avoid inconsistencies with the rest of the
> file regarding whitespace.
>
>
> -- wli
>

But it's wrong.
It should be:
> + strlen(target) + 1U, /* filesize */

strlen() already returns a size_t. You need an unsigned 1 to
not affect it. As previously stated, an integer constant
is an int, not an unsigned int unless you make it so with
"U".

>
> Index: mm1-2.6.10/usr/gen_init_cpio.c
> ===================================================================
> --- mm1-2.6.10.orig/usr/gen_init_cpio.c 2005-01-03 06:45:53.000000000 -0800
> +++ mm1-2.6.10/usr/gen_init_cpio.c 2005-01-03 09:42:18.000000000 -0800
> @@ -112,7 +112,7 @@
> (long) gid, /* gid */
> 1, /* nlink */
> (long) mtime, /* mtime */
> - strlen(target) + 1, /* filesize */
> + (unsigned)strlen(target) + 1,/* filesize */
> 3, /* major */
> 1, /* minor */
> 0, /* rmajor */
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

Cheers,
Dick Johnson
Penguin : Linux version 2.6.9 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.

2005-01-03 17:26:30

by William Lee Irwin III

[permalink] [raw]
Subject: [1/8] there is no generic_file_(get|set)_policy()

There is no generic_file_set_policy() or generic_file_get_policy.
This patch removes the dangling references to them.

Without this patch, the kernel fails to build from source with
CONFIG_NUMA=y

Signed-off-by: William Irwin <[email protected]>


Index: mm1-2.6.10/mm/filemap.c
===================================================================
--- mm1-2.6.10.orig/mm/filemap.c 2005-01-03 06:46:04.000000000 -0800
+++ mm1-2.6.10/mm/filemap.c 2005-01-03 07:50:55.000000000 -0800
@@ -1542,10 +1542,6 @@
.nopage = filemap_nopage,
.populate = filemap_populate,
.page_mkwrite = filemap_page_mkwrite,
-#ifdef CONFIG_NUMA
- .set_policy = generic_file_set_policy,
- .get_policy = generic_file_get_policy,
-#endif
};

/* This is used for a general mmap of a disk file */

2005-01-03 21:24:09

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [3/8] kill gen_init_cpio.c printk() of size_t warning

Followup to: <[email protected]>
By author: linux-os <[email protected]>
In newsgroup: linux.dev.kernel
>
> But it's wrong.
> It should be:
> > + strlen(target) + 1U, /* filesize */
>
> strlen() already returns a size_t. You need an unsigned 1 to
> not affect it. As previously stated, an integer constant
> is an int, not an unsigned int unless you make it so with
> "U".
>

Dear Wrongbot,

Bullshit. Signed is promoted to unsigned.

-hpa

2005-01-03 21:37:23

by William Lee Irwin III

[permalink] [raw]
Subject: Re: [3/8] kill gen_init_cpio.c printk() of size_t warning

Followup to: <[email protected]>
By author: linux-os <[email protected]>
In newsgroup: linux.dev.kernel
>> But it's wrong.
>> It should be:
>>> + strlen(target) + 1U, /* filesize */
>> strlen() already returns a size_t. You need an unsigned 1 to
>> not affect it. As previously stated, an integer constant
>> is an int, not an unsigned int unless you make it so with
>> "U".

On Mon, Jan 03, 2005 at 09:09:48PM +0000, H. Peter Anvin wrote:
> Dear Wrongbot,
> Bullshit. Signed is promoted to unsigned.

I'm not sure who you're responding to here, but gcc emitted an actual
warning and I was only attempting to carry out the minimal effort
necessary to silence it. I'm not really interested in creating or
being involved with controversy, just silencing the core build in the
least invasive and so on way possible, leaving deeper drivers/ issues
to the resolution of the true underlying problems.

I don't have anything to do with the code excerpt above; I merely
followed the style of the other unsigned integer coercions in the file.


-- wli

2005-01-03 21:41:47

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [3/8] kill gen_init_cpio.c printk() of size_t warning

William Lee Irwin III wrote:
>
> On Mon, Jan 03, 2005 at 09:09:48PM +0000, H. Peter Anvin wrote:
>
>>Dear Wrongbot,
>>Bullshit. Signed is promoted to unsigned.
>
> I'm not sure who you're responding to here, but gcc emitted an actual
> warning and I was only attempting to carry out the minimal effort
> necessary to silence it. I'm not really interested in creating or
> being involved with controversy, just silencing the core build in the
> least invasive and so on way possible, leaving deeper drivers/ issues
> to the resolution of the true underlying problems.
>
> I don't have anything to do with the code excerpt above; I merely
> followed the style of the other unsigned integer coercions in the file.
>

I was not responding to you, your stuff is perfectly sane.

The claim from the Wrongbot was that "foo + 1" is bad when foo is a
size_t. This is utter bullshit, since that's EXACTLY equivalent to:

foo + (size_t)1

... because of promotion rules.

-hpa

2005-01-03 21:59:50

by Al Viro

[permalink] [raw]
Subject: Re: [3/8] kill gen_init_cpio.c printk() of size_t warning

On Mon, Jan 03, 2005 at 01:36:27PM -0800, William Lee Irwin III wrote:
> I'm not sure who you're responding to here, but gcc emitted an actual
> warning and I was only attempting to carry out the minimal effort
> necessary to silence it. I'm not really interested in creating or
> being involved with controversy, just silencing the core build in the
> least invasive and so on way possible, leaving deeper drivers/ issues
> to the resolution of the true underlying problems.
>
> I don't have anything to do with the code excerpt above; I merely
> followed the style of the other unsigned integer coercions in the file.

Egads... Just use %zd for size_t. It's going to have rank no less than
that of int, so you'll get 1 converted to size_t and size_t as type of
result.

2005-01-03 22:21:34

by linux-os

[permalink] [raw]
Subject: Re: [3/8] kill gen_init_cpio.c printk() of size_t warning

On Mon, 3 Jan 2005, H. Peter Anvin wrote:

> William Lee Irwin III wrote:
>>
>> On Mon, Jan 03, 2005 at 09:09:48PM +0000, H. Peter Anvin wrote:
>>
>>> Dear Wrongbot,
>>> Bullshit. Signed is promoted to unsigned.
>>
>> I'm not sure who you're responding to here, but gcc emitted an actual
>> warning and I was only attempting to carry out the minimal effort
>> necessary to silence it. I'm not really interested in creating or
>> being involved with controversy, just silencing the core build in the
>> least invasive and so on way possible, leaving deeper drivers/ issues
>> to the resolution of the true underlying problems.
>>
>> I don't have anything to do with the code excerpt above; I merely
>> followed the style of the other unsigned integer coercions in the file.
>>
>
> I was not responding to you, your stuff is perfectly sane.
>
> The claim from the Wrongbot was that "foo + 1" is bad when foo is a size_t.
> This is utter bullshit, since that's EXACTLY equivalent to:
>
> foo + (size_t)1
>
> ... because of promotion rules.
>
> -hpa
> -

I made no such claim. I claimed that the posted fix was wrong:

>
> Index: mm1-2.6.10/usr/gen_init_cpio.c
> ===================================================================
> --- mm1-2.6.10.orig/usr/gen_init_cpio.c 2005-01-03 06:45:53.000000000 -0800
> +++ mm1-2.6.10/usr/gen_init_cpio.c 2005-01-03 09:42:18.000000000 -0800
> @@ -112,7 +112,7 @@
> (long) gid, /* gid */
> 1, /* nlink */
> (long) mtime, /* mtime */
> - strlen(target) + 1, /* filesize */
> + (unsigned)strlen(target) + 1,/* filesize */
> 3, /* major */
> 1, /* minor */
> 0, /* rmajor */
> -


This is wrong because strlen() already returns a size_t (unsigned).
This "fix" only served to quiet the compiler which was warning
about the conversion. It is a "conversion", not a "promotion".
The simple fix to quiet this conversion warning is to use 1U
as previously shown.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.9 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.

2005-01-03 22:48:05

by William Lee Irwin III

[permalink] [raw]
Subject: Re: [3/8] kill gen_init_cpio.c printk() of size_t warning

On Mon, Jan 03, 2005 at 01:36:27PM -0800, William Lee Irwin III wrote:
>> I'm not sure who you're responding to here, but gcc emitted an actual
>> warning and I was only attempting to carry out the minimal effort
>> necessary to silence it. I'm not really interested in creating or
>> being involved with controversy, just silencing the core build in the
>> least invasive and so on way possible, leaving deeper drivers/ issues
>> to the resolution of the true underlying problems.
>> I don't have anything to do with the code excerpt above; I merely
>> followed the style of the other unsigned integer coercions in the file.

On Mon, Jan 03, 2005 at 09:55:03PM +0000, Al Viro wrote:
> Egads... Just use %zd for size_t. It's going to have rank no less than
> that of int, so you'll get 1 converted to size_t and size_t as type of
> result.

My personal preference was to do that, but it would have been
inconsistent with the approach used in the rest of the file.


-- wli

2005-01-03 23:05:24

by Ben Pfaff

[permalink] [raw]
Subject: Re: [3/8] kill gen_init_cpio.c printk() of size_t warning

Al Viro <[email protected]> writes:

> Egads... Just use %zd for size_t.

%zu?

2005-01-04 00:01:23

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [3/8] kill gen_init_cpio.c printk() of size_t warning

Followup to: <[email protected]>
By author: Ben Pfaff <[email protected]>
In newsgroup: linux.dev.kernel
>
> Al Viro <[email protected]> writes:
>
> > Egads... Just use %zd for size_t.
>
> %zu?
>

Right, %zu for size_t, %zd for ssize_t.

-hpa