diff options
| author | Paul Eggert | 2012-07-10 14:48:34 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-07-10 14:48:34 -0700 |
| commit | e99a530f8cdca3ccd9e739cd092ed9865d12fe89 (patch) | |
| tree | c2bef9f80ff9910be17757a83f61caed02146d0a /src/sysdep.c | |
| parent | c59592b32f5b5808c12720bfd37ea73b473fa1db (diff) | |
| download | emacs-e99a530f8cdca3ccd9e739cd092ed9865d12fe89.tar.gz emacs-e99a530f8cdca3ccd9e739cd092ed9865d12fe89.zip | |
Simplify by avoiding confusing use of strncpy etc.
Diffstat (limited to 'src/sysdep.c')
| -rw-r--r-- | src/sysdep.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/sysdep.c b/src/sysdep.c index 0639b72285a..ed926760414 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -2744,9 +2744,11 @@ system_process_attributes (Lisp_Object pid) | |||
| 2744 | char procbuf[1025], *p, *q; | 2744 | char procbuf[1025], *p, *q; |
| 2745 | int fd; | 2745 | int fd; |
| 2746 | ssize_t nread; | 2746 | ssize_t nread; |
| 2747 | const char *cmd = NULL; | 2747 | static char const default_cmd[] = "???"; |
| 2748 | const char *cmd = default_cmd; | ||
| 2749 | int cmdsize = sizeof default_cmd - 1; | ||
| 2748 | char *cmdline = NULL; | 2750 | char *cmdline = NULL; |
| 2749 | ptrdiff_t cmdsize = 0, cmdline_size; | 2751 | ptrdiff_t cmdline_size; |
| 2750 | unsigned char c; | 2752 | unsigned char c; |
| 2751 | printmax_t proc_id; | 2753 | printmax_t proc_id; |
| 2752 | int ppid, pgrp, sess, tty, tpgid, thcount; | 2754 | int ppid, pgrp, sess, tty, tpgid, thcount; |
| @@ -2808,11 +2810,6 @@ system_process_attributes (Lisp_Object pid) | |||
| 2808 | } | 2810 | } |
| 2809 | else | 2811 | else |
| 2810 | q = NULL; | 2812 | q = NULL; |
| 2811 | if (cmd == NULL) | ||
| 2812 | { | ||
| 2813 | cmd = "???"; | ||
| 2814 | cmdsize = 3; | ||
| 2815 | } | ||
| 2816 | /* Command name is encoded in locale-coding-system; decode it. */ | 2813 | /* Command name is encoded in locale-coding-system; decode it. */ |
| 2817 | cmd_str = make_unibyte_string (cmd, cmdsize); | 2814 | cmd_str = make_unibyte_string (cmd, cmdsize); |
| 2818 | decoded_cmd = code_convert_string_norecord (cmd_str, | 2815 | decoded_cmd = code_convert_string_norecord (cmd_str, |
| @@ -2950,14 +2947,9 @@ system_process_attributes (Lisp_Object pid) | |||
| 2950 | } | 2947 | } |
| 2951 | if (!cmdline_size) | 2948 | if (!cmdline_size) |
| 2952 | { | 2949 | { |
| 2953 | if (!cmd) | ||
| 2954 | cmd = "???"; | ||
| 2955 | if (!cmdsize) | ||
| 2956 | cmdsize = strlen (cmd); | ||
| 2957 | cmdline_size = cmdsize + 2; | 2950 | cmdline_size = cmdsize + 2; |
| 2958 | cmdline = xmalloc (cmdline_size + 1); | 2951 | cmdline = xmalloc (cmdline_size + 1); |
| 2959 | strcpy (cmdline, "["); | 2952 | sprintf (cmdline, "[%.*s]", cmdsize, cmd); |
| 2960 | strcat (strncat (cmdline, cmd, cmdsize), "]"); | ||
| 2961 | } | 2953 | } |
| 2962 | emacs_close (fd); | 2954 | emacs_close (fd); |
| 2963 | /* Command line is encoded in locale-coding-system; decode it. */ | 2955 | /* Command line is encoded in locale-coding-system; decode it. */ |