Alvaro Herrera <[EMAIL PROTECTED]> writes:
> The question that jumps at me is why are you using SPI inside a type's
> output function?  You should really avoid doing that.

Offhand it seems like it should work, but the real problem is that there
are probably a ton of code paths besides SPI_getvalue() that would need
to be changed to make it bulletproof.  I don't have a big problem with
adding SPI_push/pop inside SPI_getvalue, but what else might need to
change?

> If you absolutely need to do it, enclosing the function in SPI_push/pop
> seems to me the least bad answer.

That would be the Wrong Thing if the function could ever be called when
*not* connected to SPI, which of course is the normal case for a type
I/O function.  Correct code would be something like

        bool connected = false;

        if (_SPI_curid + 1 == _SPI_connected)           /* connected */
        {
                connected = true;
                SPI_push();
        }

        ... do it ...

        if (connected)
                SPI_pop();

and this is only possible inside spi.c because those variables aren't
exported.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to