Re: [hatari-devel] Fwrite warnings |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] Fwrite warnings
- From: Uwe Seimet <Uwe.Seimet@xxxxxxxxx>
- Date: Thu, 27 Oct 2022 09:08:09 +0200
- Authentication-results: strato.com; dkim=none
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1666854510; s=strato-dkim-0002; d=seimet.de; h=In-Reply-To:References:Message-ID:Subject:To:From:Date:Cc:Date:From: Subject:Sender; bh=ZzSlyVrWMTVzSdkTpfOGg0vrChYyl5f5RsaP/t6J/PU=; b=TWga3/CypEIX47xRqE8+1p8if0Os0ObiXHIAplMUzCH/DaiuCLJPzUrugWbnv4GyXr 77OIqIQjMFF4gXbuuOZaKJDvtM+9EEkKgQVkybDFfkLtNwa7ADSqjSmsevTpGeqoSMzT 7OtcjCTuTmGhvUtswTrO//+AA/J8PdweEQxZ5KDWZ/scEZtrvk5X+GcnoV5DGx/jG1Cb nyoOMGdFK/SPE6dZxb3Fp107k5UTecWzEprUyWHebZkIJTFKogI17rCiyycZKeBvIJeP BwtAvOl0dkTKOGF8NO4ezw9THheQC4ddbxomiLC/X+GIsrF3ETftefQkjy940gqJCN4S UVvw==
Hi Eero,
Yes, that fixed has helped. All warnings are gone.
In general it might be a good idea to suppress consecutive duplicate
warnings but just to display them once with a count, e.g.
WARN : GEMDOS Fwrite() to 'ROOT.O' file, opened as read-only (3 times)
instead of
WARN : GEMDOS Fwrite() to 'ROOT.O' file, opened as read-only
WARN : GEMDOS Fwrite() to 'ROOT.O' file, opened as read-only
WARN : GEMDOS Fwrite() to 'ROOT.O' file, opened as read-only
Best regards
Uwe
> Hi Uwe,
>
> On 27.10.2022 0.39, Eero Tamminen wrote:
> > On 26.10.2022 15.16, Uwe Seimet wrote:
> >>> with the latest sources I get tons of warnings when, for instance, I
> >>> compile
> >>> with Pure C. I have never seen these warnings before.
> >>>
> >>> WARN : GEMDOS Fwrite() to 'ROOT.O' file, opened as read-only
> >
> > This is from following commit:
> > https://git.tuxfamily.org/hatari/hatari.git/commit/?id=799020b84d0224a4bb38f2b892a8ecdd1c11bcc1
> >
> >
> >>> Is this a bug or can these warnings be switched off? There are so
> >>> many of
> >>> them that it's hard to see the actually relevant messages.
> > >
> > > I just noticed that I also get these warnings
> > > for files definitely opened for writing, i.e.
> > > opened with fopen(FILENAME, "w") with Pure C.
> >
> > Can you provide GEMDOS trace around that warning?
>
> Only case where I can see this happening:
> * Fwrite() done for a FD from Fcreate(), not Fopen(), and
> * That FD number being reused from an earlier, already Fclose()d,
> read-only Fopen() call
>
>
> Attached patch should fix that. Does it help?
>
>
> - Eero
> diff --git a/src/gemdos.c b/src/gemdos.c
> index 1c3e4010..5067ac54 100644
> --- a/src/gemdos.c
> +++ b/src/gemdos.c
> @@ -896,6 +896,8 @@ static void restore_file_handle_info(int i, FILE_HANDLE *handle)
> fclose(fp);
> return;
> }
> + /* used only for warnings, ignore those after restore */
> + handle->bReadOnly = false;
> handle->FileHandle = fp;
> }
>
> @@ -2021,8 +2023,11 @@ static bool GemDOS_Create(uint32_t Params)
> * - GEMDOS_FILE_ATTRIB_WRITECLOSE (FA_ARCHIVE)
> * (set automatically by GemDOS >= 0.15)
> */
> + FileHandles[Index].bReadOnly = false;
> if (Mode & GEMDOS_FILE_ATTRIB_READONLY)
> {
> + /* enable write warnings */
> + FileHandles[Index].bReadOnly = true;
> /* after closing, file should be read-only */
> if (chmod(szActualFileName, S_IRUSR|S_IRGRP|S_IROTH))
> {
> @@ -3883,8 +3888,9 @@ void GemDOS_Info(FILE *fp, uint32_t bShowOpcodes)
> {
> if (!FileHandles[i].bUsed)
> continue;
> - fprintf(fp, "- %d (0x%x): %s\n", i + BASE_FILEHANDLE,
> - FileHandles[i].Basepage, FileHandles[i].szActualName);
> + fprintf(fp, "- %d (0x%x): %s (%s)\n", i + BASE_FILEHANDLE,
> + FileHandles[i].Basepage, FileHandles[i].szActualName,
> + FileHandles[i].bReadOnly ? "ro" : "rw");
> used++;
> }
> if (!used)