On Fri, 13 May 2022 at 22:09, Peter Delevoryas <p...@fb.com> wrote > I was actually intentionally skipping that. If serial_hd(i) > doesn’t exist, the function will return NULL. > > Chardev *serial_hd(int i) > { > assert(i >= 0); > if (i < num_serial_hds) { > return serial_hds[i]; > } > return NULL; > } > > So then, the serial device’s CharBackend’s “Chardev *chr” > will be initialized as NULL. Looking at all of the > usage of this attribute in “hw/char/serial.c”, I think > that’s ok, the read/write functions will just be no-ops. > They all have guards for “chr == NULL”.
Yes, this is deliberate. We added these in commit 12051d82f0040 because otherwise lots of board/SoC code would have to create NullChardev dummy backends (or forget to and then crash depending on the user's commandline). thanks -- PMM