On 2003-09-28 at 03:18:59 [-0700], Ingo Weinhold wrote: > > On 2003-09-27 at 22:10:08 [+0200], Tyler Dauwalder wrote: > > > [...] > > > > @@ -538,11 +554,20 @@ > > > > // _kern_get_disk_device_data > > > > status_t > > > > _kern_get_disk_device_data(partition_id id, bool deviceOnly, bool > > > > shadow, > > > > - user_disk_device_data *buffer, size_t > > > > bufferSize, > > > > + user_disk_device_data *_buffer, size_t > > > > bufferSize, > > > > size_t *neededSize) > > > > { > > > > - if (!buffer && bufferSize > 0) > > > > + if (!_buffer && bufferSize > 0) > > > > return B_BAD_VALUE; > > > > + > > > > + // copy in > > > > + user_disk_device_data *buffer = bufferSize > 0 > > > > + ? > > > > reinterpret_cast<user_disk_device_data*>(malloc(bufferSize)) > > > > > > static_cast should be sufficient, BTW. No need for the sledgehammer. ;-) > > > > I'm not sure I see how reinterpret_cast<> is a sledgehammer. > > Well, it cast anything to anything else. static_cast only casts between > compatible pointer or reference types and even heeds consts. Ah, I see; I took sledgehammer to imply it was heavy, a la dynamic_cast<>. At any rate, doesn't reinterpret_cast<> heed consts, as well? I thought only const_cast<> got to muck around with those. > > > However, we should be more careful here. Since bufferSize may have a > > > huge > > > value, we shouldn't malloc() kernel memory unchecked. > > > So, either we set a reasonably great size constraint (100KB or so maybe) > > > or > > > do a dry run with the UserDataWriter to get the > > > exactly required size. I'd prefer the latter solution. > > > > Okay, I go for the latter. > > Since I need the tests working, I'm going to fix that myself, now. I hope, > you don't mind. Sure, help yourself. :-) -Tyler