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>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andreas Mohr 2016-01-03 11:13:02 +00:00 committed by Andrew Borodin
parent 842a723f9b
commit b9797d6637
7 changed files with 26 additions and 27 deletions

View File

@ -54,7 +54,7 @@ mc_event_init (GError ** mcerror)
if (mc_event_grouplist != NULL) if (mc_event_grouplist != NULL)
{ {
mc_propagate_error (mcerror, 1, "%s", _("Event system already initialized")); mc_propagate_error (mcerror, 0, "%s", _("Event system already initialized"));
return FALSE; return FALSE;
} }
@ -64,7 +64,7 @@ mc_event_init (GError ** mcerror)
if (mc_event_grouplist == NULL) if (mc_event_grouplist == NULL)
{ {
mc_propagate_error (mcerror, 2, "%s", _("Failed to initialize event system")); mc_propagate_error (mcerror, 0, "%s", _("Failed to initialize event system"));
return FALSE; return FALSE;
} }
@ -80,7 +80,7 @@ mc_event_deinit (GError ** mcerror)
if (mc_event_grouplist == NULL) if (mc_event_grouplist == NULL)
{ {
mc_propagate_error (mcerror, 3, "%s", _("Event system not initialized")); mc_propagate_error (mcerror, 0, "%s", _("Event system not initialized"));
return FALSE; return FALSE;
} }

View File

@ -74,7 +74,7 @@ mc_event_add (const gchar * event_group_name, const gchar * event_name,
if (mc_event_grouplist == NULL || event_group_name == NULL || event_name == NULL if (mc_event_grouplist == NULL || event_group_name == NULL || event_name == NULL
|| event_callback == NULL) || event_callback == NULL)
{ {
mc_propagate_error (mcerror, 1, "%s", _("Check input data! Some of parameters are NULL!")); mc_propagate_error (mcerror, 0, "%s", _("Check input data! Some of parameters are NULL!"));
return FALSE; return FALSE;
} }
@ -172,7 +172,7 @@ mc_event_get_event_group_by_name (const gchar * event_group_name, gboolean creat
(GDestroyNotify) mc_event_group_destroy_value); (GDestroyNotify) mc_event_group_destroy_value);
if (event_group == NULL) if (event_group == NULL)
{ {
mc_propagate_error (mcerror, 1, _("Unable to create group '%s' for events!"), mc_propagate_error (mcerror, 0, _("Unable to create group '%s' for events!"),
event_group_name); event_group_name);
return NULL; return NULL;
} }
@ -197,7 +197,7 @@ mc_event_get_event_by_name (GTree * event_group, const gchar * event_name, gbool
callbacks = g_ptr_array_new (); callbacks = g_ptr_array_new ();
if (callbacks == NULL) if (callbacks == NULL)
{ {
mc_propagate_error (mcerror, 1, _("Unable to create event '%s'!"), event_name); mc_propagate_error (mcerror, 0, _("Unable to create event '%s'!"), event_name);
return NULL; return NULL;
} }
g_tree_insert (event_group, g_strdup (event_name), (gpointer) callbacks); g_tree_insert (event_group, g_strdup (event_name), (gpointer) callbacks);

View File

@ -110,7 +110,7 @@ mc_serialize_str (const char prefix, const char *data, GError ** error)
{ {
if (data == NULL) if (data == NULL)
{ {
g_set_error (error, MC_ERROR, -1, "mc_serialize_str(): Input data is NULL."); g_set_error (error, MC_ERROR, 0, "mc_serialize_str(): Input data is NULL.");
return NULL; return NULL;
} }
return g_strdup_printf ("%c%zd" SRLZ_DELIM_S "%s", prefix, strlen (data), data); return g_strdup_printf ("%c%zd" SRLZ_DELIM_S "%s", prefix, strlen (data), data);
@ -135,14 +135,13 @@ mc_deserialize_str (const char prefix, const char *data, GError ** error)
if ((data == NULL) || (strlen (data) == 0)) if ((data == NULL) || (strlen (data) == 0))
{ {
g_set_error (error, MC_ERROR, -1, FUNC_NAME ": Input data is NULL or empty."); g_set_error (error, MC_ERROR, 0, FUNC_NAME ": Input data is NULL or empty.");
return NULL; return NULL;
} }
if (*data != prefix) if (*data != prefix)
{ {
g_set_error (error, MC_ERROR, -2, FUNC_NAME ": String prefix doesn't equal to '%c'", g_set_error (error, MC_ERROR, 0, FUNC_NAME ": String prefix doesn't equal to '%c'", prefix);
prefix);
return NULL; return NULL;
} }
@ -154,14 +153,14 @@ mc_deserialize_str (const char prefix, const char *data, GError ** error)
semi_ptr = strchr (data + 1, SRLZ_DELIM_C); semi_ptr = strchr (data + 1, SRLZ_DELIM_C);
if (semi_ptr == NULL) if (semi_ptr == NULL)
{ {
g_set_error (error, MC_ERROR, -3, g_set_error (error, MC_ERROR, 0,
FUNC_NAME ": Length delimiter '%c' doesn't exists", SRLZ_DELIM_C); FUNC_NAME ": Length delimiter '%c' doesn't exists", SRLZ_DELIM_C);
return NULL; return NULL;
} }
semi_offset = semi_ptr - (data + 1); semi_offset = semi_ptr - (data + 1);
if (semi_offset >= BUF_TINY) if (semi_offset >= BUF_TINY)
{ {
g_set_error (error, MC_ERROR, -3, FUNC_NAME ": Too big string length"); g_set_error (error, MC_ERROR, 0, FUNC_NAME ": Too big string length");
return NULL; return NULL;
} }
strncpy (buffer, data + 1, semi_offset); strncpy (buffer, data + 1, semi_offset);
@ -172,7 +171,7 @@ mc_deserialize_str (const char prefix, const char *data, GError ** error)
if (data_len > strlen (data)) if (data_len > strlen (data))
{ {
g_set_error (error, MC_ERROR, -3, g_set_error (error, MC_ERROR, 0,
FUNC_NAME FUNC_NAME
": Specified data length (%zd) is greater than actual data length (%zd)", ": Specified data length (%zd) is greater than actual data length (%zd)",
data_len, strlen (data)); data_len, strlen (data));

View File

@ -1094,7 +1094,7 @@ vfs_path_serialize (const vfs_path_t * vpath, GError ** mcerror)
if ((vpath == NULL) || (vfs_path_elements_count (vpath) == 0)) if ((vpath == NULL) || (vfs_path_elements_count (vpath) == 0))
{ {
mc_propagate_error (mcerror, -1, "%s", "vpath object is empty"); mc_propagate_error (mcerror, 0, "%s", "vpath object is empty");
return NULL; return NULL;
} }
@ -1177,7 +1177,7 @@ vfs_path_deserialize (const char *data, GError ** mcerror)
{ {
g_free (element); g_free (element);
vfs_path_free (vpath); vfs_path_free (vpath);
g_set_error (mcerror, MC_ERROR, -1, "Unable to find VFS class by name '%s'", cfg_value); g_set_error (mcerror, MC_ERROR, 0, "Unable to find VFS class by name '%s'", cfg_value);
g_free (cfg_value); g_free (cfg_value);
mc_config_deinit (cpath); mc_config_deinit (cpath);
return NULL; return NULL;
@ -1209,7 +1209,7 @@ vfs_path_deserialize (const char *data, GError ** mcerror)
if (vfs_path_elements_count (vpath) == 0) if (vfs_path_elements_count (vpath) == 0)
{ {
vfs_path_free (vpath); vfs_path_free (vpath);
g_set_error (mcerror, MC_ERROR, -1, "No any path elements found"); g_set_error (mcerror, MC_ERROR, 0, "No any path elements found");
return NULL; return NULL;
} }
vpath->str = vfs_path_to_str_flags (vpath, 0, VPF_NONE); vpath->str = vfs_path_to_str_flags (vpath, 0, VPF_NONE);

View File

@ -648,7 +648,7 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, gboolean c
localfile_vpath = mc_getlocalcopy (filename_vpath); localfile_vpath = mc_getlocalcopy (filename_vpath);
if (localfile_vpath == NULL) if (localfile_vpath == NULL)
{ {
mc_propagate_error (mcerror, -1, _("Cannot fetch a local copy of %s"), mc_propagate_error (mcerror, 0, _("Cannot fetch a local copy of %s"),
vfs_path_as_str (filename_vpath)); vfs_path_as_str (filename_vpath));
return FALSE; return FALSE;
} }
@ -715,7 +715,7 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, gboolean c
if (got_data == -1) if (got_data == -1)
{ {
mc_propagate_error (mcerror, -1, "%s", _("Pipe failed")); mc_propagate_error (mcerror, 0, "%s", _("Pipe failed"));
return FALSE; return FALSE;
} }
@ -733,7 +733,7 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, gboolean c
} }
else else
{ {
mc_propagate_error (mcerror, -1, "%s", _("Regular expression error")); mc_propagate_error (mcerror, 0, "%s", _("Regular expression error"));
} }
} }

View File

@ -75,7 +75,7 @@ sftpfs_open_socket (struct vfs_s_super *super, GError ** mcerror)
if (super->path_element->host == NULL || *super->path_element->host == '\0') if (super->path_element->host == NULL || *super->path_element->host == '\0')
{ {
mc_propagate_error (mcerror, -1, "%s", _("sftp: Invalid host name.")); mc_propagate_error (mcerror, 0, "%s", _("sftp: Invalid host name."));
return -1; return -1;
} }
@ -107,7 +107,7 @@ sftpfs_open_socket (struct vfs_s_super *super, GError ** mcerror)
if (e != 0) if (e != 0)
{ {
mc_propagate_error (mcerror, -1, _("sftp: %s"), gai_strerror (e)); mc_propagate_error (mcerror, 0, _("sftp: %s"), gai_strerror (e));
my_socket = -1; my_socket = -1;
goto ret; goto ret;
} }
@ -134,9 +134,9 @@ sftpfs_open_socket (struct vfs_s_super *super, GError ** mcerror)
close (my_socket); close (my_socket);
if (errno == EINTR && tty_got_interrupt ()) if (errno == EINTR && tty_got_interrupt ())
mc_propagate_error (mcerror, -1, "%s", _("sftp: connection interrupted by user")); mc_propagate_error (mcerror, 0, "%s", _("sftp: connection interrupted by user"));
else if (res->ai_next == NULL) else if (res->ai_next == NULL)
mc_propagate_error (mcerror, -1, _("sftp: connection to server failed: %s"), mc_propagate_error (mcerror, 0, _("sftp: connection to server failed: %s"),
unix_error_string (errno)); unix_error_string (errno));
else else
continue; continue;
@ -276,7 +276,7 @@ sftpfs_open_connection_ssh_key (struct vfs_s_super *super, GError ** mcerror)
g_free (p); g_free (p);
if (passwd == NULL) if (passwd == NULL)
mc_propagate_error (mcerror, -1, "%s", _("sftp: Passphrase is empty.")); mc_propagate_error (mcerror, 0, "%s", _("sftp: Passphrase is empty."));
else else
{ {
ret_value = (libssh2_userauth_publickey_fromfile (super_data->session, ret_value = (libssh2_userauth_publickey_fromfile (super_data->session,
@ -327,7 +327,7 @@ sftpfs_open_connection_ssh_password (struct vfs_s_super *super, GError ** mcerro
g_free (p); g_free (p);
if (passwd == NULL) if (passwd == NULL)
mc_propagate_error (mcerror, -1, "%s", _("sftp: Password is empty.")); mc_propagate_error (mcerror, 0, "%s", _("sftp: Password is empty."));
else else
{ {
while ((rc = libssh2_userauth_password (super_data->session, super->path_element->user, while ((rc = libssh2_userauth_password (super_data->session, super->path_element->user,
@ -387,7 +387,7 @@ sftpfs_open_connection (struct vfs_s_super *super, GError ** mcerror)
rc = libssh2_session_startup (super_data->session, super_data->socket_handle); rc = libssh2_session_startup (super_data->session, super_data->socket_handle);
if (rc != 0) if (rc != 0)
{ {
mc_propagate_error (mcerror, -1, _("sftp: Failure establishing SSH session: (%d)"), rc); mc_propagate_error (mcerror, 0, _("sftp: Failure establishing SSH session: (%d)"), rc);
return (-1); return (-1);
} }

View File

@ -248,7 +248,7 @@ sftpfs_read_file (vfs_file_handler_t * file_handler, char *buffer, size_t count,
if (file_handler == NULL || file_handler->data == NULL) if (file_handler == NULL || file_handler->data == NULL)
{ {
mc_propagate_error (mcerror, -1, "%s", mc_propagate_error (mcerror, 0, "%s",
_("sftp: No file handler data present for reading file")); _("sftp: No file handler data present for reading file"));
return -1; return -1;
} }