Daniel Jacobowitz wrote: > On Thu, Jan 31, 2008 at 02:56:22AM +0000, Pedro Alves wrote: >> static void >> -hostio_error (char *own_buf, int error) >> +hostio_error (char *own_buf) >> { >> - int fileio_error = errno_to_fileio_errno (error); >> - >> - sprintf (own_buf, "F-1,%x", fileio_error); >> + sprintf (own_buf, "F-1,"); >> + the_target->hostio_last_error (own_buf + 4); >> } >> > > Pretty much anything can change errno. That includes sprintf. So you > have to save the value of errno before you call back into the C > library, in general, or you might print some other error than the one > you want. > > For now, how about the_target->hostio_last_error which converts to a > protocol error and returns that? Then we can call it before sprintf. > If you're going to accept my proposed extension to the protocol, then I'd go the other direction and move the sprintf to the target method, because then I'd write two numbers in own_buf; an int return wouldn't suffice. See attached. I'll post the other patch seperatelly. -- Pedro Alves