[haiku-commits] Re: r42459 - haiku/trunk/src/system/boot/platform/openfirmware

  • From: Alexander von Gluck <kallisti5@xxxxxxxxxxx>
  • To: <haiku-commits@xxxxxxxxxxxxx>
  • Date: Wed, 20 Jul 2011 17:19:54 -0500

On Thu, 21 Jul 2011 00:02:52 +0200, Axel Dörfler wrote:
kallisti5@xxxxxxxxxxx wrote:
-       if ((length = of_getprop(root, "device_type", buffer,
sizeof(buffer) - 1))
-                       == OF_FAILED)
-               return;
+
+       // TODO : Probe other OpenFirmware platforms and set gMachine as
needed
+
+       int length = of_getprop(root, "device_type", buffer,
sizeof(buffer) - 1);

Did you intentionally remove the error checking?

Yup. In the grand scheme of things we don't care if the property exists or not.

As it was programmed, if any property encountered is missing the device detection gives up.. as these property presences may vary based on OpenFirmware implementation..
thats bad.

With this said, after double-checking this, length could be -1 on OF_FAILED which means buffer[-1]
which probably wouldn't be good.

Will refactor with OF_FAILED checks.

        if (!strcasecmp("chrp", buffer))
                gMachine = MACHINE_CHRP;
-       else if (!strcasecmp("bootrom", buffer))
+       else //(bootrom) + QEMU

That doesn't look like cleanup.

we were looking for bootrom, however OpenBIOS doesn't provide this OF parameter as it is Apple specific and not in the IEEE spec. So if it is a CHRP platform we need to know,
otherwise we assume it's a modern, new-world mac.

+       if (gMachine & MACHINE_QEMU)
+               dprintf("OpenBIOS (QEMU?) OpenFirmware machine detected\n");
+       else if (gMachine & MACHINE_PEGASOS)

Coding style: use ((a & b) != 0)

will fix.


Thanks!

 -- Alex


Other related posts: