Skip to contentSkip to conversation

save_flags() should take unsigned long

PATCH Pavel Machek 4 participants 5 messages Mar 4, 2002 – Mar 26, 2002

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

Hi!

...and here's patch to fix it... Please apply.
Pavel

drivers/ide/ide.c +1 -1
@@ -1864,7 +1864,7 @@
 	ide_drive_t *drive;
 	ide_hwgroup_t *hwgroup;
 	unsigned int p, major, minor;
-	long flags;
+	unsigned long flags;
 
 	if ((drive = get_info_ptr(i_rdev)) == NULL)
 		return -ENODEV;
drivers/scsi/sym53c8xx.c +1 -1
@@ -14111,7 +14111,7 @@
 	if (len)
 		return -EINVAL;
 	else {
-		long flags;
+		unsigned long flags;
 
 		NCR_LOCK_NCB(np, flags);
 		ncr_usercmd (np);
include/linux/skbuff.h +2 -2
@@ -588,7 +588,7 @@
 
 static inline struct sk_buff *skb_dequeue(struct sk_buff_head *list)
 {
-	long flags;
+	unsigned long flags;
 	struct sk_buff *result;
 
 	spin_lock_irqsave(&list->lock, flags);
@@ -737,7 +737,7 @@
 
 static inline struct sk_buff *skb_dequeue_tail(struct sk_buff_head *list)
 {
-	long flags;
+	unsigned long flags;
 	struct sk_buff *result;
 
 	spin_lock_irqsave(&list->lock, flags);
Signature · 2 lines
(about SSSCA) "I don't say this lightly.  However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy." --hpa
#1 lore raw
Quoted 3 lines · Pavel Machek

Hi!

...and here's patch to fix it... Please apply.

The correct way to fix this would be:

<in suitable header-file; suggestions welcome>
typedef flags_t unsigned long;

If someone can just come up with the proper header-file to use, I have a patch that fixes up all (?) code.

My suggestion would be to keep the typedef in the same header-file as save_flags/restore_flags.

Regards: David Weinehall
_ _
// David Weinehall <[email protected]> /> Northern lights wander \\

//  Maintainer of the v2.0 kernel   //  Dance across the winter sky //
\>  http://www.acc.umu.se/~tao/    </   Full colour fire           </
#2 lore raw
Quoted 9 lines · David Weinehall
Quoted 3 lines · Pavel Machek

Hi!

...and here's patch to fix it... Please apply.

The correct way to fix this would be:

<in suitable header-file; suggestions welcome>
typedef flags_t unsigned long;

I don't think it takes an 'unsigned long'. Instead, it takes 'size_t'. This makes it work in all architectures because 'size_t' is the size of a register.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).

Windows-2000/Professional isn't.

#3 lore raw
In reply to Pavel Machek

Hi!

Quoted 5 lines
Quoted 2 lines

...and here's patch to fix it... Please apply.

The correct way to fix this would be:

Quoted 8 lines

<in suitable header-file; suggestions welcome>
typedef flags_t unsigned long;

If someone can just come up with the proper header-file to use, I have a patch that fixes up all (?) code.

My suggestion would be to keep the typedef in the same header-file as save_flags/restore_flags.

Yep, looks good. Try to feed it as trivial to rusty ;-).
Pavel

Signature · 2 lines
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.
#4 lore raw
In reply to Pavel Machek
Quoted 4 lines · David Weinehall

The correct way to fix this would be:

<in suitable header-file; suggestions welcome>
typedef flags_t unsigned long;

You mean typedef unsigned long flags_t;

However, people will still write:

{
	int flags;

	save_flags(flags);

because 'int' is faster to type than 'flags_t'. About the only way you're going to stop it dead is to do:

typedef struct { unsigned long val; } flags_t;

and then save_flags(x)/restore_flags(x) use (x).val

Signature · 2 lines
Russell King ([email protected])                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html