Re: Portable OpenSSH on Linux: confusing error message with scp

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



On Tue, 5 Apr 2022, Leah Neukirchen wrote:

> scp.c does rougly:
> 
>                 exists = stat(np, &stb) == 0;
>                 /* ... stuff elided ... */
>                 if ((ofd = open(np, O_WRONLY|O_CREAT, mode)) == -1) {
> bad:                    run_err("%s: %s", np, strerror(errno));
>                         continue;
>                 }

> would be a suitable override, or perhaps you have a better idea.

Without looking at the code (asking the Linux kernel developers to
fix their errno… probably doesn’t have a chance), maybe:

		nexists = stat(np, &stb) ? errno : 0;
		/*…*/
		if (nexists ||
		    (ofd = open(np, O_WRONLY|O_CREAT, mode)) == -1) {
			run_err("%s: %s", np,
			    strerror(nexists ? nexists : errno));
			continue;
		}
(and do something about that bad label)

Or even:
		if (!(exists = stat(np, &stb) == 0))
			goto bad;
		/*… rest as above */
But only if that elided stuff isn’t important. If it is, maybe:

		nexists = stat(np, &stb) ? errno : 0;
		/*…*/
		if ((ofd = open(np, O_WRONLY|O_CREAT, mode)) == -1) {
			run_err("%s: %s", np,
			    strerror(nexists ? nexists : errno));
			continue;
		}

Just a shoot into the blue that came to me while reading the mail.

bye,
//mirabilos
-- 
Sometimes they [people] care too much: pretty printers [and syntax highligh-
ting, d.A.] mechanically produce pretty output that accentuates irrelevant
detail in the program, which is as sensible as putting all the prepositions
in English text in bold font.	-- Rob Pike in "Notes on Programming in C"
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev




[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux