From: Christian Groessler Date: Tue, 9 Jul 2013 21:39:42 +0000 (+0200) Subject: close IOCB if open failed -- otherwise is is still marked as "in use" X-Git-Tag: V2.15~223^2~73 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f04dc3570c942d373f6781d90e505d157422a4c5;p=cc65 close IOCB if open failed -- otherwise is is still marked as "in use" --- diff --git a/libsrc/atari/graphics.s b/libsrc/atari/graphics.s index cad5412bc..ab26ed0da 100644 --- a/libsrc/atari/graphics.s +++ b/libsrc/atari/graphics.s @@ -10,12 +10,12 @@ .export __graphics .import findfreeiocb - .import __do_oserror,__oserror + .import __oserror .import fddecusage .import clriocb .import fdtoiocb .import newfd - .import scrdev + .import scrdev .importzp tmp1,tmp2,tmp3 .include "atari.inc" @@ -97,7 +97,12 @@ doopen: txa stx __oserror rts -cioerr: jsr fddecusage ; decrement usage counter of fd as open failed - jmp __do_oserror +cioerr: sty tmp3 ; remember error code + lda #CLOSE + sta ICCOM,x + jsr CIOV ; close IOCB again since open failed + jsr fddecusage ; and decrement usage counter of fd + lda tmp3 ; put error code into A + jmp __mappederrno .endproc ; __graphics diff --git a/libsrc/atari/open.s b/libsrc/atari/open.s index 8aeff9ed4..306cf52c2 100644 --- a/libsrc/atari/open.s +++ b/libsrc/atari/open.s @@ -140,8 +140,12 @@ finish: php plp bpl ok - jsr fddecusage ; decrement usage counter of fd as open failed - tya ; put error code into A + sty tmp3 ; remember error code + lda #CLOSE + sta ICCOM,x + jsr CIOV ; close IOCB again since open failed + jsr fddecusage ; and decrement usage counter of fd + lda tmp3 ; put error code into A jmp __mappederrno ok: lda tmp2 ; get fd diff --git a/libsrc/atari/posixdirent.s b/libsrc/atari/posixdirent.s index 3417e4bfc..a722b3b06 100644 --- a/libsrc/atari/posixdirent.s +++ b/libsrc/atari/posixdirent.s @@ -63,6 +63,9 @@ .endproc cioerr: sty __oserror + lda #CLOSE + sta ICCOM,x + jsr CIOV ; close IOCB again since open failed jmp return0 .proc _readdir