public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] include/scsi/scsi.h replace u8 in 2.5.69
@ 2003-05-14  6:39 Douglas Gilbert
  2003-05-14  8:02 ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Douglas Gilbert @ 2003-05-14  6:39 UTC (permalink / raw)
  To: linux-scsi

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

Here is a simple patch to replace the single occurrence
of "u8" with "u_char" in include/scsi/scsi.h .

While working on an application (to test sgbind) that
needs to include the kernel rather than the glibc
headers, it is a nuisance to have to add:
    typedef unsigned char u8;
before including /usr/src/linux/include/scsi/scsi.h

Perhaps we should be moving toward the official C99
typedef: uint8_t which is defined in stdint.h

Doug Gilbert

[-- Attachment #2: scsi_h_2569.diff --]
[-- Type: text/plain, Size: 274 bytes --]

--- linux/include/scsi/scsi.h	2003-02-11 08:39:21.000000000 +1000
+++ linux/include/scsi/scsi.h2569fix	2003-05-14 12:41:48.000000000 +1000
@@ -201,7 +201,7 @@
  * ScsiLun: 8 byte LUN.
  */
 typedef struct scsi_lun {
-	u8 scsi_lun[8];
+	u_char scsi_lun[8];
 } ScsiLun;
 
 /*

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

* Re: [PATCH] include/scsi/scsi.h replace u8 in 2.5.69
  2003-05-14  6:39 [PATCH] include/scsi/scsi.h replace u8 in 2.5.69 Douglas Gilbert
@ 2003-05-14  8:02 ` Christoph Hellwig
  2003-05-14 13:05   ` Jeff Garzik
  2003-05-14 13:10   ` Douglas Gilbert
  0 siblings, 2 replies; 6+ messages in thread
From: Christoph Hellwig @ 2003-05-14  8:02 UTC (permalink / raw)
  To: Douglas Gilbert; +Cc: linux-scsi

On Wed, May 14, 2003 at 04:39:43PM +1000, Douglas Gilbert wrote:
> Here is a simple patch to replace the single occurrence
> of "u8" with "u_char" in include/scsi/scsi.h .

That's wrong.  No userland should include kernwel headers.
(and u_char is a non-standard type, too).


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

* Re: [PATCH] include/scsi/scsi.h replace u8 in 2.5.69
  2003-05-14  8:02 ` Christoph Hellwig
@ 2003-05-14 13:05   ` Jeff Garzik
  2003-05-14 13:10   ` Douglas Gilbert
  1 sibling, 0 replies; 6+ messages in thread
From: Jeff Garzik @ 2003-05-14 13:05 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Douglas Gilbert, linux-scsi

Christoph Hellwig wrote:
> On Wed, May 14, 2003 at 04:39:43PM +1000, Douglas Gilbert wrote:
> 
>>Here is a simple patch to replace the single occurrence
>>of "u8" with "u_char" in include/scsi/scsi.h .
> 
> 
> That's wrong.  No userland should include kernwel headers.
> (and u_char is a non-standard type, too).


Agreed.  And like Douglas guessed, uint8_t is preferred over u_char :)

	Jeff




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

* Re: [PATCH] include/scsi/scsi.h replace u8 in 2.5.69
  2003-05-14  8:02 ` Christoph Hellwig
  2003-05-14 13:05   ` Jeff Garzik
@ 2003-05-14 13:10   ` Douglas Gilbert
  2003-05-14 13:14     ` Christoph Hellwig
  2003-05-14 13:54     ` Andries Brouwer
  1 sibling, 2 replies; 6+ messages in thread
From: Douglas Gilbert @ 2003-05-14 13:10 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-scsi

Christoph Hellwig wrote:
> On Wed, May 14, 2003 at 04:39:43PM +1000, Douglas Gilbert wrote:
> 
>>Here is a simple patch to replace the single occurrence
>>of "u8" with "u_char" in include/scsi/scsi.h .
> 
> 
> That's wrong.  No userland should include kernwel headers.
> (and u_char is a non-standard type, too).

Christoph,
That's naive. In some case glibc's headers and libraries
(e.g. mknod) are an impediment to development.

If I add one define to ~linux/include/scsi/sg.h just
how long do you think it takes for it to appear in
/usr/include/scsi/sg.h?
It can take over a year in my experience.

Put another way, the sg.h header that applications use
should match the sg driver in the kernel not the glibc
version. The glibc maintainers add nothing to the
interface (apart from inertia and some bugs once in a
while).

Applications that include sg.h typically include scsi.h
as well. Only when I change sg.h does this problem arise.

It is one thing to state a policy (e.g. "no user program
should include kernel headers") it is another thing to
gratuitously break those few programs that have good
reason not to follow that policy.

Doug Gilbert




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

* Re: [PATCH] include/scsi/scsi.h replace u8 in 2.5.69
  2003-05-14 13:10   ` Douglas Gilbert
@ 2003-05-14 13:14     ` Christoph Hellwig
  2003-05-14 13:54     ` Andries Brouwer
  1 sibling, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2003-05-14 13:14 UTC (permalink / raw)
  To: Douglas Gilbert; +Cc: Christoph Hellwig, linux-scsi

On Wed, May 14, 2003 at 11:10:27PM +1000, Douglas Gilbert wrote:
> Christoph,
> That's naive. In some case glibc's headers and libraries
> (e.g. mknod) are an impediment to development.
> 
> If I add one define to ~linux/include/scsi/sg.h just
> how long do you think it takes for it to appear in
> /usr/include/scsi/sg.h?

As long as it takes you to send the same diff to Ullrich.

> It can take over a year in my experience.
> 
> Put another way, the sg.h header that applications use
> should match the sg driver in the kernel

What kernel?  I run everything from 2.2.2x + local hacks to latest
2.5 on one box.

> It is one thing to state a policy (e.g. "no user program
> should include kernel headers") it is another thing to
> gratuitously break those few programs that have good
> reason not to follow that policy.

So get declarations for u8 into your program.  It's a kernel
header for a reason and if you ignore the advise _you_ have
to work around the problems arising from it not the kernel.


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

* Re: [PATCH] include/scsi/scsi.h replace u8 in 2.5.69
  2003-05-14 13:10   ` Douglas Gilbert
  2003-05-14 13:14     ` Christoph Hellwig
@ 2003-05-14 13:54     ` Andries Brouwer
  1 sibling, 0 replies; 6+ messages in thread
From: Andries Brouwer @ 2003-05-14 13:54 UTC (permalink / raw)
  To: Douglas Gilbert; +Cc: Christoph Hellwig, linux-scsi

On Wed, May 14, 2003 at 11:10:27PM +1000, Douglas Gilbert wrote:

> >That's wrong.  No userland should include kernwel headers.
> >(and u_char is a non-standard type, too).
> 
> Christoph,
> That's naive. In some case glibc's headers and libraries
> (e.g. mknod) are an impediment to development.
> 
> If I add one define to ~linux/include/scsi/sg.h just
> how long do you think it takes for it to appear in
> /usr/include/scsi/sg.h?
> It can take over a year in my experience.

Consider: the same binaries are used on a wide range of kernels.
Consider: the same sources are compiled on machines with a
wide range of installed kernel sources.

It is undesirable that recompilation is needed when
a kernel is upgraded (or downgraded).

Thus, the robust setup uses its own copy of the headers,
or perhaps uses something like

#include <header.h>
#ifndef MY_CONSTANT
#define MY_CONSTANT 12345
#endif

to make sure that things compile with old and new *libc, with
old and new kernels.

Next, this robust setup must make sure that things not only
compile but also run, i.e., must be prepared to deal with EINVAL
or ENOSYS etc in case it is run on a kernel that does not yet
know about this new stuff.

Andries


[There is an different case for a private copy of the headers:
the kernel headers change all the time, and sometimes such
changes cause obscure and difficult-to-debug errors in utilities.
I still recall the case, many years ago, of a struct field that
was made unsigned, causing a change in semantics for a comparison.
User space software is easier to debug when the corresponding
binary does not depend in obscure ways on the kernel source
installed when it was compiled.]


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

end of thread, other threads:[~2003-05-14 13:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-14  6:39 [PATCH] include/scsi/scsi.h replace u8 in 2.5.69 Douglas Gilbert
2003-05-14  8:02 ` Christoph Hellwig
2003-05-14 13:05   ` Jeff Garzik
2003-05-14 13:10   ` Douglas Gilbert
2003-05-14 13:14     ` Christoph Hellwig
2003-05-14 13:54     ` Andries Brouwer

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