Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: sys/dev/scsipi/scsipi_base.c



On Sun, 06 Jan 2008, Paul Goyette wrote:
>> } > memcpy(inqbuf->vendor, "ADAPTEC ACB-4000            ", 28);
>> } > yet inqbuf->vendor is declared in struct scsipi_inquiry_data as:
>> } > char    vendor[8];
>> } and is followed by:
>> }   char    product[16];
>> }   char    revision[4];
>> } so the memcpy updates all 3 fields :-)
> Shouldn't we at least replace the constant 28 with a macro that gives a 
> hint of what's going on?

Or encapsulate it in a union with three separate strings on one side and
a single string on the other side.

> It's still going to be grotty code, and won't address the issue of a  
> "perverse introduction of gratuitous padding" mentioned in another    
> message in this thread,                                               

That problem is not worth worrying about in practice, given that we have
so much code that assumes we know how the compiler will lay out structs
in memory.

--apb (Alan Barrett)



Home | Main Index | Thread Index | Old Index