diff options
| author | Paul Eggert | 2019-07-13 12:31:41 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-07-13 16:53:21 -0700 |
| commit | 9a34591ddd5ef481af5bad1fd0b76c39fce4e8e3 (patch) | |
| tree | c5f2b9c885ab9ee375dea5f980bd7bccb388a2ee /src/sysdep.c | |
| parent | 1178f98f2c0973dd1f8a66cbb4de20c0d7af3271 (diff) | |
| download | emacs-9a34591ddd5ef481af5bad1fd0b76c39fce4e8e3.tar.gz emacs-9a34591ddd5ef481af5bad1fd0b76c39fce4e8e3.zip | |
Use a better buffer size in emacs_perror
* src/sysdep.c (emacs_perror): Since the buffer is for avoiding
interleaving, size it via PIPE_BUF not BUFSIZ.
* src/sysstdio.h (PIPE_BUF): Provide a default.
Diffstat (limited to 'src/sysdep.c')
| -rw-r--r-- | src/sysdep.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/sysdep.c b/src/sysdep.c index 4c3d546962c..9301405943b 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -2711,10 +2711,10 @@ emacs_perror (char const *message) | |||
| 2711 | ? initial_argv[0] : "emacs"); | 2711 | ? initial_argv[0] : "emacs"); |
| 2712 | /* Write it out all at once, if it's short; this is less likely to | 2712 | /* Write it out all at once, if it's short; this is less likely to |
| 2713 | be interleaved with other output. */ | 2713 | be interleaved with other output. */ |
| 2714 | char buf[BUFSIZ]; | 2714 | char buf[min (PIPE_BUF, MAX_ALLOCA)]; |
| 2715 | int nbytes = snprintf (buf, sizeof buf, "%s: %s: %s\n", | 2715 | int nbytes = snprintf (buf, sizeof buf, "%s: %s: %s\n", |
| 2716 | command, message, error_string); | 2716 | command, message, error_string); |
| 2717 | if (0 <= nbytes && nbytes < BUFSIZ) | 2717 | if (0 <= nbytes && nbytes < sizeof buf) |
| 2718 | emacs_write (STDERR_FILENO, buf, nbytes); | 2718 | emacs_write (STDERR_FILENO, buf, nbytes); |
| 2719 | else | 2719 | else |
| 2720 | { | 2720 | { |