[PATCH 1/3] everywhere: Change SetLastError to RestoreLastError if appropriate