Re: Where's f_audioctx set?
On Tue, 13 Jul 2021, Mouse wrote: However, the KASSERT, combined with AUDIO_SETINFO doing something, indicates that it clearly is getting set. So, I'm obviously missing something. What? I had need to look into the audio code some time back, so I think I can explain this: audio_open() in audio.c: 1. fills audio_file_t *af; 2. calls fd_allocfile(, ); 3. does fd_clone() with `af' as last param; 4. fd_clone() does fp->f_data = af; 5. f_data is just f_undata.fd_data And, since f_undata is a union, step 4 sets fd_audioctx. -RVP
re: Where's f_audioctx set?
i'm not sure, but i'm guessing that it happens here: audio.c:2491: error = fd_clone(fp, fd, flags, _fileops, af); audio.c:3541: error = fd_clone(fp, fd, flags, _fileops, af); audio.c:8167: error = fd_clone(fp, fd, flags, _fileops, af); with kern_descrip.c:1882:fd_clone(file_t *fp, unsigned fd, int flag, const struct fileops *fops, kern_descrip.c:1883: void *data) [ ... ] kern_descrip.c:1895: fp->f_data = data; .mrg.
Re: Where's f_audioctx set?
>> However, the KASSERT, combined with AUDIO_SETINFO doing something, >> indicates that it clearly is getting set. So, I'm obviously missing >> something. >> What? > I had need to look into the audio code some time back, so I think I > can explain this: > audio_open() in audio.c: > 1. fills audio_file_t *af; > 2. calls fd_allocfile(, ); > 3. does fd_clone() with `af' as last param; > 4. fd_clone() does fp->f_data = af; > 5. f_data is just f_undata.fd_data > And, since f_undata is a union, step 4 sets fd_audioctx. Oh, ick. (This causes all fields of f_undata other than fd_data, or, possibly, other void * fields - I'd have to think about that - to go undefined, as in accessing them produces undefined behaviour. I'm slightly surprised undefined-behaviour detectors haven't been kicking up a fuss.) Thank you for explaining! /~\ The ASCII Mouse \ / Ribbon Campaign X Against HTMLmo...@rodents-montreal.org / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B