Re: git: 7f0dc6e2cdfa - main - mkimg(1): process non-seekable output gracefully
- In reply to: Brooks Davis : "Re: git: 7f0dc6e2cdfa - main - mkimg(1): process non-seekable output gracefully"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 13 Mar 2024 08:09:30 UTC
12.03.2024 23:58, Brooks Davis wrote:
[skip]
> It seems weird to cache a single member. For that matter, caching
> anyting seems like overkill given than format_selected() just returns a
> global variable's value.
It is a habit. Why not? :-)
I do not like calling a method multiple times after an object settled.
[skip]
>> +#if defined(SPARSE_WRITE)
>> + /*
>> + * sparse_write() fails if output is not seekable so fail early
>> + * not wasting some load unless output format is raw
>> + */
>> + if (strcmp("raw", format_name) &&
>> + lseek(outfd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE)
>> + errx(EX_USAGE, "%s: output must be seekable", format_name);
>> +#endif
>
> Maybe add a flag for non-seeking formats rather than hardcoding a
> strcmp?
I thought about it. A change would be much more invasive without real benefits.
I believe there will not be any more non-sparse formats other than raw.
If there will, we can improve the code later.
For now, I prefer keeping the code and the change as simple as possible.
Eugene