From 585d598d8ebfabd4831cca9967d47804a0f885df Mon Sep 17 00:00:00 2001
From: Andreas Mohr <and@gmx.li>
Date: Sun, 3 Jan 2016 11:13:02 +0000
Subject: [PATCH] fix #3269 use meaningful errno or 0
use real errno or set it to 0
when no meaningful error code exists
for current user error message
Signed-off-by: Andreas Mohr <and@gmx.li>
---
lib/event/event.c | 6 +++---
lib/event/manage.c | 6 +++---
lib/serialize.c | 12 ++++++------
lib/vfs/path.c | 6 +++---
src/filemanager/ext.c | 6 +++---
src/vfs/sftpfs/connection.c | 14 +++++++-------
src/vfs/sftpfs/file.c | 2 +-
7 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/lib/event/event.c b/lib/event/event.c
index 426dd30..4f4b830 100644
a
|
b
|
mc_event_init (GError ** mcerror) |
54 | 54 | |
55 | 55 | if (mc_event_grouplist != NULL) |
56 | 56 | { |
57 | | mc_propagate_error (mcerror, 1, "%s", _("Event system already initialized")); |
| 57 | mc_propagate_error (mcerror, 0, "%s", _("Event system already initialized")); |
58 | 58 | return FALSE; |
59 | 59 | } |
60 | 60 | |
… |
… |
mc_event_init (GError ** mcerror) |
64 | 64 | |
65 | 65 | if (mc_event_grouplist == NULL) |
66 | 66 | { |
67 | | mc_propagate_error (mcerror, 2, "%s", _("Failed to initialize event system")); |
| 67 | mc_propagate_error (mcerror, 0, "%s", _("Failed to initialize event system")); |
68 | 68 | return FALSE; |
69 | 69 | } |
70 | 70 | |
… |
… |
mc_event_deinit (GError ** mcerror) |
80 | 80 | |
81 | 81 | if (mc_event_grouplist == NULL) |
82 | 82 | { |
83 | | mc_propagate_error (mcerror, 3, "%s", _("Event system not initialized")); |
| 83 | mc_propagate_error (mcerror, 0, "%s", _("Event system not initialized")); |
84 | 84 | return FALSE; |
85 | 85 | } |
86 | 86 | |
diff --git a/lib/event/manage.c b/lib/event/manage.c
index 9d216b8..118a16e 100644
a
|
b
|
mc_event_add (const gchar * event_group_name, const gchar * event_name, |
74 | 74 | if (mc_event_grouplist == NULL || event_group_name == NULL || event_name == NULL |
75 | 75 | || event_callback == NULL) |
76 | 76 | { |
77 | | mc_propagate_error (mcerror, 1, "%s", _("Check input data! Some of parameters are NULL!")); |
| 77 | mc_propagate_error (mcerror, 0, "%s", _("Check input data! Some of parameters are NULL!")); |
78 | 78 | return FALSE; |
79 | 79 | } |
80 | 80 | |
… |
… |
mc_event_get_event_group_by_name (const gchar * event_group_name, gboolean creat |
172 | 172 | (GDestroyNotify) mc_event_group_destroy_value); |
173 | 173 | if (event_group == NULL) |
174 | 174 | { |
175 | | mc_propagate_error (mcerror, 1, _("Unable to create group '%s' for events!"), |
| 175 | mc_propagate_error (mcerror, 0, _("Unable to create group '%s' for events!"), |
176 | 176 | event_group_name); |
177 | 177 | return NULL; |
178 | 178 | } |
… |
… |
mc_event_get_event_by_name (GTree * event_group, const gchar * event_name, gbool |
197 | 197 | callbacks = g_ptr_array_new (); |
198 | 198 | if (callbacks == NULL) |
199 | 199 | { |
200 | | mc_propagate_error (mcerror, 1, _("Unable to create event '%s'!"), event_name); |
| 200 | mc_propagate_error (mcerror, 0, _("Unable to create event '%s'!"), event_name); |
201 | 201 | return NULL; |
202 | 202 | } |
203 | 203 | g_tree_insert (event_group, g_strdup (event_name), (gpointer) callbacks); |
diff --git a/lib/serialize.c b/lib/serialize.c
index 96b946f..27909eb 100644
a
|
b
|
mc_serialize_str (const char prefix, const char *data, GError ** error) |
110 | 110 | { |
111 | 111 | if (data == NULL) |
112 | 112 | { |
113 | | g_set_error (error, MC_ERROR, -1, "mc_serialize_str(): Input data is NULL."); |
| 113 | g_set_error (error, MC_ERROR, 0, "mc_serialize_str(): Input data is NULL."); |
114 | 114 | return NULL; |
115 | 115 | } |
116 | 116 | return g_strdup_printf ("%c%zd" SRLZ_DELIM_S "%s", prefix, strlen (data), data); |
… |
… |
mc_deserialize_str (const char prefix, const char *data, GError ** error) |
135 | 135 | |
136 | 136 | if ((data == NULL) || (strlen (data) == 0)) |
137 | 137 | { |
138 | | g_set_error (error, MC_ERROR, -1, FUNC_NAME ": Input data is NULL or empty."); |
| 138 | g_set_error (error, MC_ERROR, 0, FUNC_NAME ": Input data is NULL or empty."); |
139 | 139 | return NULL; |
140 | 140 | } |
141 | 141 | |
142 | 142 | if (*data != prefix) |
143 | 143 | { |
144 | | g_set_error (error, MC_ERROR, -2, FUNC_NAME ": String prefix doesn't equal to '%c'", |
| 144 | g_set_error (error, MC_ERROR, 0, FUNC_NAME ": String prefix doesn't equal to '%c'", |
145 | 145 | prefix); |
146 | 146 | return NULL; |
147 | 147 | } |
… |
… |
mc_deserialize_str (const char prefix, const char *data, GError ** error) |
154 | 154 | semi_ptr = strchr (data + 1, SRLZ_DELIM_C); |
155 | 155 | if (semi_ptr == NULL) |
156 | 156 | { |
157 | | g_set_error (error, MC_ERROR, -3, |
| 157 | g_set_error (error, MC_ERROR, 0, |
158 | 158 | FUNC_NAME ": Length delimiter '%c' doesn't exists", SRLZ_DELIM_C); |
159 | 159 | return NULL; |
160 | 160 | } |
161 | 161 | semi_offset = semi_ptr - (data + 1); |
162 | 162 | if (semi_offset >= BUF_TINY) |
163 | 163 | { |
164 | | g_set_error (error, MC_ERROR, -3, FUNC_NAME ": Too big string length"); |
| 164 | g_set_error (error, MC_ERROR, 0, FUNC_NAME ": Too big string length"); |
165 | 165 | return NULL; |
166 | 166 | } |
167 | 167 | strncpy (buffer, data + 1, semi_offset); |
… |
… |
mc_deserialize_str (const char prefix, const char *data, GError ** error) |
172 | 172 | |
173 | 173 | if (data_len > strlen (data)) |
174 | 174 | { |
175 | | g_set_error (error, MC_ERROR, -3, |
| 175 | g_set_error (error, MC_ERROR, 0, |
176 | 176 | FUNC_NAME |
177 | 177 | ": Specified data length (%zd) is greater than actual data length (%zd)", |
178 | 178 | data_len, strlen (data)); |
diff --git a/lib/vfs/path.c b/lib/vfs/path.c
index 5f64850..7c90eb0 100644
a
|
b
|
vfs_path_serialize (const vfs_path_t * vpath, GError ** mcerror) |
1094 | 1094 | |
1095 | 1095 | if ((vpath == NULL) || (vfs_path_elements_count (vpath) == 0)) |
1096 | 1096 | { |
1097 | | mc_propagate_error (mcerror, -1, "%s", "vpath object is empty"); |
| 1097 | mc_propagate_error (mcerror, 0, "%s", "vpath object is empty"); |
1098 | 1098 | return NULL; |
1099 | 1099 | |
1100 | 1100 | } |
… |
… |
vfs_path_deserialize (const char *data, GError ** mcerror) |
1177 | 1177 | { |
1178 | 1178 | g_free (element); |
1179 | 1179 | vfs_path_free (vpath); |
1180 | | g_set_error (mcerror, MC_ERROR, -1, "Unable to find VFS class by name '%s'", cfg_value); |
| 1180 | g_set_error (mcerror, MC_ERROR, 0, "Unable to find VFS class by name '%s'", cfg_value); |
1181 | 1181 | g_free (cfg_value); |
1182 | 1182 | mc_config_deinit (cpath); |
1183 | 1183 | return NULL; |
… |
… |
vfs_path_deserialize (const char *data, GError ** mcerror) |
1209 | 1209 | if (vfs_path_elements_count (vpath) == 0) |
1210 | 1210 | { |
1211 | 1211 | vfs_path_free (vpath); |
1212 | | g_set_error (mcerror, MC_ERROR, -1, "No any path elements found"); |
| 1212 | g_set_error (mcerror, MC_ERROR, 0, "No any path elements found"); |
1213 | 1213 | return NULL; |
1214 | 1214 | } |
1215 | 1215 | vpath->str = vfs_path_to_str_flags (vpath, 0, VPF_NONE); |
diff --git a/src/filemanager/ext.c b/src/filemanager/ext.c
index 44bc387..f7466c8 100644
a
|
b
|
regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, gboolean c |
648 | 648 | localfile_vpath = mc_getlocalcopy (filename_vpath); |
649 | 649 | if (localfile_vpath == NULL) |
650 | 650 | { |
651 | | mc_propagate_error (mcerror, -1, _("Cannot fetch a local copy of %s"), |
| 651 | mc_propagate_error (mcerror, 0, _("Cannot fetch a local copy of %s"), |
652 | 652 | vfs_path_as_str (filename_vpath)); |
653 | 653 | return FALSE; |
654 | 654 | } |
… |
… |
regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, gboolean c |
715 | 715 | |
716 | 716 | if (got_data == -1) |
717 | 717 | { |
718 | | mc_propagate_error (mcerror, -1, "%s", _("Pipe failed")); |
| 718 | mc_propagate_error (mcerror, 0, "%s", _("Pipe failed")); |
719 | 719 | return FALSE; |
720 | 720 | } |
721 | 721 | |
… |
… |
regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, gboolean c |
733 | 733 | } |
734 | 734 | else |
735 | 735 | { |
736 | | mc_propagate_error (mcerror, -1, "%s", _("Regular expression error")); |
| 736 | mc_propagate_error (mcerror, 0, "%s", _("Regular expression error")); |
737 | 737 | } |
738 | 738 | } |
739 | 739 | |
diff --git a/src/vfs/sftpfs/connection.c b/src/vfs/sftpfs/connection.c
index fceb961..f573346 100644
a
|
b
|
sftpfs_open_socket (struct vfs_s_super *super, GError ** mcerror) |
75 | 75 | |
76 | 76 | if (super->path_element->host == NULL || *super->path_element->host == '\0') |
77 | 77 | { |
78 | | mc_propagate_error (mcerror, -1, "%s", _("sftp: Invalid host name.")); |
| 78 | mc_propagate_error (mcerror, 0, "%s", _("sftp: Invalid host name.")); |
79 | 79 | return -1; |
80 | 80 | } |
81 | 81 | |
… |
… |
sftpfs_open_socket (struct vfs_s_super *super, GError ** mcerror) |
107 | 107 | |
108 | 108 | if (e != 0) |
109 | 109 | { |
110 | | mc_propagate_error (mcerror, -1, _("sftp: %s"), gai_strerror (e)); |
| 110 | mc_propagate_error (mcerror, 0, _("sftp: %s"), gai_strerror (e)); |
111 | 111 | my_socket = -1; |
112 | 112 | goto ret; |
113 | 113 | } |
… |
… |
sftpfs_open_socket (struct vfs_s_super *super, GError ** mcerror) |
134 | 134 | close (my_socket); |
135 | 135 | |
136 | 136 | if (errno == EINTR && tty_got_interrupt ()) |
137 | | mc_propagate_error (mcerror, -1, "%s", _("sftp: connection interrupted by user")); |
| 137 | mc_propagate_error (mcerror, 0, "%s", _("sftp: connection interrupted by user")); |
138 | 138 | else if (res->ai_next == NULL) |
139 | | mc_propagate_error (mcerror, -1, _("sftp: connection to server failed: %s"), |
| 139 | mc_propagate_error (mcerror, 0, _("sftp: connection to server failed: %s"), |
140 | 140 | unix_error_string (errno)); |
141 | 141 | else |
142 | 142 | continue; |
… |
… |
sftpfs_open_connection_ssh_key (struct vfs_s_super *super, GError ** mcerror) |
276 | 276 | g_free (p); |
277 | 277 | |
278 | 278 | if (passwd == NULL) |
279 | | mc_propagate_error (mcerror, -1, "%s", _("sftp: Passphrase is empty.")); |
| 279 | mc_propagate_error (mcerror, 0, "%s", _("sftp: Passphrase is empty.")); |
280 | 280 | else |
281 | 281 | { |
282 | 282 | ret_value = (libssh2_userauth_publickey_fromfile (super_data->session, |
… |
… |
sftpfs_open_connection_ssh_password (struct vfs_s_super *super, GError ** mcerro |
327 | 327 | g_free (p); |
328 | 328 | |
329 | 329 | if (passwd == NULL) |
330 | | mc_propagate_error (mcerror, -1, "%s", _("sftp: Password is empty.")); |
| 330 | mc_propagate_error (mcerror, 0, "%s", _("sftp: Password is empty.")); |
331 | 331 | else |
332 | 332 | { |
333 | 333 | while ((rc = libssh2_userauth_password (super_data->session, super->path_element->user, |
… |
… |
sftpfs_open_connection (struct vfs_s_super *super, GError ** mcerror) |
387 | 387 | rc = libssh2_session_startup (super_data->session, super_data->socket_handle); |
388 | 388 | if (rc != 0) |
389 | 389 | { |
390 | | mc_propagate_error (mcerror, -1, _("sftp: Failure establishing SSH session: (%d)"), rc); |
| 390 | mc_propagate_error (mcerror, 0, _("sftp: Failure establishing SSH session: (%d)"), rc); |
391 | 391 | return (-1); |
392 | 392 | } |
393 | 393 | |
diff --git a/src/vfs/sftpfs/file.c b/src/vfs/sftpfs/file.c
index 1af0a44..d95de9b 100644
a
|
b
|
sftpfs_read_file (vfs_file_handler_t * file_handler, char *buffer, size_t count, |
248 | 248 | |
249 | 249 | if (file_handler == NULL || file_handler->data == NULL) |
250 | 250 | { |
251 | | mc_propagate_error (mcerror, -1, "%s", |
| 251 | mc_propagate_error (mcerror, 0, "%s", |
252 | 252 | _("sftp: No file handler data present for reading file")); |
253 | 253 | return -1; |
254 | 254 | } |