Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Mar 2024 15:09:30 +0700
From:      Eugene Grosbein <eugen@freebsd.org>
To:        Brooks Davis <brooks@freebsd.org>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org
Subject:   Re: git: 7f0dc6e2cdfa - main - mkimg(1): process non-seekable output gracefully
Message-ID:  <7ddc5445-3afe-2447-b400-60f21366935f@freebsd.org>
In-Reply-To: <ZfCJuOQv69Ljmqut@spindle.one-eyed-alien.net>
References:  <202403121600.42CG0OKT011953@gitrepo.freebsd.org> <ZfCJuOQv69Ljmqut@spindle.one-eyed-alien.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7ddc5445-3afe-2447-b400-60f21366935f>