mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 21:06:38 +02:00
Removed sizeof(char) and useless type casts from void* to another pointer type (patch from Leonid Evdokimov)
This commit is contained in:
@@ -105,7 +105,7 @@ weechat_lua_exec (struct t_plugin_script *script,
|
||||
ret_value = strdup ((char *) lua_tostring (lua_current_interpreter, -1));
|
||||
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
|
||||
{
|
||||
ret_i = (int *)malloc (sizeof (int));
|
||||
ret_i = malloc (sizeof (*ret_i));
|
||||
if (ret_i)
|
||||
*ret_i = lua_tonumber (lua_current_interpreter, -1);
|
||||
ret_value = ret_i;
|
||||
|
||||
@@ -119,9 +119,9 @@ weechat_perl_exec (struct t_plugin_script *script,
|
||||
|
||||
#ifndef MULTIPLICITY
|
||||
length = strlen (script->interpreter) + strlen (function) + 3;
|
||||
func = (char *)malloc (length * sizeof (char));
|
||||
func = malloc (length);
|
||||
if (!func)
|
||||
return NULL;
|
||||
return NULL;
|
||||
snprintf (func, length, "%s::%s", (char *) script->interpreter, function);
|
||||
#else
|
||||
(void) length;
|
||||
@@ -135,7 +135,7 @@ weechat_perl_exec (struct t_plugin_script *script,
|
||||
|
||||
/* are we loading the script file ? */
|
||||
if (strcmp (function, "weechat_perl_load_eval_file") != 0)
|
||||
perl_current_script = script;
|
||||
perl_current_script = script;
|
||||
|
||||
count = perl_call_argv (func, G_EVAL | G_SCALAR, argv);
|
||||
ret_value = NULL;
|
||||
@@ -149,42 +149,42 @@ weechat_perl_exec (struct t_plugin_script *script,
|
||||
weechat_gettext ("%s%s: error: %s"),
|
||||
weechat_prefix ("error"), "perl", SvPV_nolen (ERRSV));
|
||||
(void) POPs; /* poping the 'undef' */
|
||||
mem_err = 0;
|
||||
mem_err = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count != 1)
|
||||
{
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: function \"%s\" must "
|
||||
"return one valid value (%d)"),
|
||||
weechat_prefix ("error"), "perl", function, count);
|
||||
mem_err = 0;
|
||||
}
|
||||
mem_err = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ret_type == WEECHAT_SCRIPT_EXEC_STRING)
|
||||
{
|
||||
ret_s = newSVsv(POPs);
|
||||
ret_value = strdup (SvPV_nolen (ret_s));
|
||||
SvREFCNT_dec (ret_s);
|
||||
}
|
||||
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
|
||||
{
|
||||
ret_i = (int *)malloc (sizeof (int));
|
||||
if (ret_i)
|
||||
*ret_i = POPi;
|
||||
ret_value = ret_i;
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
{
|
||||
if (ret_type == WEECHAT_SCRIPT_EXEC_STRING)
|
||||
{
|
||||
ret_s = newSVsv(POPs);
|
||||
ret_value = strdup (SvPV_nolen (ret_s));
|
||||
SvREFCNT_dec (ret_s);
|
||||
}
|
||||
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
|
||||
{
|
||||
ret_i = malloc (sizeof (*ret_i));
|
||||
if (ret_i)
|
||||
*ret_i = POPi;
|
||||
ret_value = ret_i;
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: function \"%s\" is "
|
||||
"internally misused"),
|
||||
weechat_prefix ("error"), "perl", function);
|
||||
mem_err = 0;
|
||||
}
|
||||
}
|
||||
mem_err = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PUTBACK;
|
||||
@@ -197,11 +197,11 @@ weechat_perl_exec (struct t_plugin_script *script,
|
||||
|
||||
if (!ret_value && (mem_err == 1))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: not enough memory in function "
|
||||
"\"%s\""),
|
||||
weechat_prefix ("error"), "perl", function);
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
|
||||
@@ -137,7 +137,7 @@ weechat_python_exec (struct t_plugin_script *script,
|
||||
else if (PyInt_Check (rc) && (ret_type == WEECHAT_SCRIPT_EXEC_INT))
|
||||
{
|
||||
|
||||
ret_i = (int *)malloc (sizeof (int));
|
||||
ret_i = malloc (sizeof (*ret_i));
|
||||
if (ret_i)
|
||||
*ret_i = (int) PyInt_AsLong(rc);
|
||||
ret_value = ret_i;
|
||||
@@ -277,8 +277,8 @@ weechat_python_load (char *filename)
|
||||
"sub-interpreter"),
|
||||
weechat_prefix ("error"), "python");
|
||||
fclose (fp);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
return 0;
|
||||
/* PyEval_ReleaseLock (); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* PyThreadState_Swap (python_current_interpreter); */
|
||||
@@ -293,10 +293,10 @@ weechat_python_load (char *filename)
|
||||
weechat_prefix ("error"), "python");
|
||||
fclose (fp);
|
||||
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* adding $weechat_dir/python in $PYTHONPATH */
|
||||
@@ -304,19 +304,19 @@ weechat_python_load (char *filename)
|
||||
w_home = weechat_info_get ("weechat_dir");
|
||||
if (w_home)
|
||||
{
|
||||
len = strlen (w_home) + 1 + strlen("python") + 1;
|
||||
p_home = (char *)malloc (len * sizeof (char));
|
||||
if (p_home)
|
||||
{
|
||||
snprintf (p_home, len, "%s/python", w_home);
|
||||
path = PyString_FromString (p_home);
|
||||
if (path != NULL)
|
||||
{
|
||||
PyList_Insert (python_path, 0, path);
|
||||
Py_DECREF (path);
|
||||
}
|
||||
free (p_home);
|
||||
}
|
||||
len = strlen (w_home) + 1 + strlen("python") + 1;
|
||||
p_home = malloc (len);
|
||||
if (p_home)
|
||||
{
|
||||
snprintf (p_home, len, "%s/python", w_home);
|
||||
path = PyString_FromString (p_home);
|
||||
if (path != NULL)
|
||||
{
|
||||
PyList_Insert (python_path, 0, path);
|
||||
Py_DECREF (path);
|
||||
}
|
||||
free (p_home);
|
||||
}
|
||||
}
|
||||
|
||||
/* define some constants */
|
||||
@@ -344,15 +344,15 @@ weechat_python_load (char *filename)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PySys_SetObject("stdout", weechat_outputs) == -1)
|
||||
if (PySys_SetObject("stdout", weechat_outputs) == -1)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to redirect stdout"),
|
||||
weechat_prefix ("error"), "python");
|
||||
}
|
||||
if (PySys_SetObject("stderr", weechat_outputs) == -1)
|
||||
if (PySys_SetObject("stderr", weechat_outputs) == -1)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to redirect stderr"),
|
||||
weechat_prefix ("error"), "python");
|
||||
}
|
||||
@@ -365,22 +365,22 @@ weechat_python_load (char *filename)
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to parse file \"%s\""),
|
||||
weechat_prefix ("error"), "python", filename);
|
||||
fclose (fp);
|
||||
|
||||
if (PyErr_Occurred ()) PyErr_Print ();
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
|
||||
/* if script was registered, removing from list */
|
||||
if (python_current_script != NULL)
|
||||
{
|
||||
script_remove (weechat_python_plugin, &python_scripts,
|
||||
python_current_script);
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
if (PyErr_Occurred ())
|
||||
PyErr_Print ();
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
|
||||
/* if script was registered, removing from list */
|
||||
if (python_current_script != NULL)
|
||||
script_remove (weechat_python_plugin, &python_scripts,
|
||||
python_current_script);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (PyErr_Occurred ()) PyErr_Print ();
|
||||
if (PyErr_Occurred ())
|
||||
PyErr_Print ();
|
||||
|
||||
fclose (fp);
|
||||
|
||||
@@ -391,11 +391,12 @@ weechat_python_load (char *filename)
|
||||
"found (or failed) in file \"%s\""),
|
||||
weechat_prefix ("error"), "python", filename);
|
||||
|
||||
if (PyErr_Occurred ()) PyErr_Print ();
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
|
||||
return 0;
|
||||
if (PyErr_Occurred ())
|
||||
PyErr_Print ();
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
python_current_script->interpreter = (PyThreadState *) python_current_interpreter;
|
||||
|
||||
@@ -198,7 +198,7 @@ weechat_ruby_exec (struct t_plugin_script *script,
|
||||
}
|
||||
else if ((TYPE(rc) == T_FIXNUM) && (ret_type == WEECHAT_SCRIPT_EXEC_INT))
|
||||
{
|
||||
ret_i = (int *)malloc (sizeof (int));
|
||||
ret_i = malloc (sizeof (*ret_i));
|
||||
if (ret_i)
|
||||
*ret_i = NUM2INT(rc);
|
||||
ret_value = ret_i;
|
||||
|
||||
@@ -911,8 +911,8 @@ script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
{
|
||||
char *option_fullname, *return_value;
|
||||
|
||||
option_fullname = (char *)malloc ((strlen (script->name) +
|
||||
strlen (option) + 2) * sizeof (char));
|
||||
option_fullname = malloc ((strlen (script->name) +
|
||||
strlen (option) + 2));
|
||||
if (!option_fullname)
|
||||
return NULL;
|
||||
|
||||
@@ -939,8 +939,8 @@ script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
char *option_fullname;
|
||||
int return_code;
|
||||
|
||||
option_fullname = (char *)malloc ((strlen (script->name) +
|
||||
strlen (option) + 2) * sizeof (char));
|
||||
option_fullname = malloc ((strlen (script->name) +
|
||||
strlen (option) + 2));
|
||||
if (!option_fullname)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ script_callback_alloc ()
|
||||
{
|
||||
struct t_script_callback *new_script_callback;
|
||||
|
||||
new_script_callback = (struct t_script_callback *)malloc (sizeof (struct t_script_callback));
|
||||
new_script_callback = malloc (sizeof (*new_script_callback));
|
||||
if (new_script_callback)
|
||||
{
|
||||
new_script_callback->script = NULL;
|
||||
|
||||
@@ -101,7 +101,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
|
||||
/* add hook for config option */
|
||||
length = strlen (weechat_plugin->name) + 32;
|
||||
string = (char *)malloc (length * sizeof (char));
|
||||
string = malloc (length);
|
||||
if (string)
|
||||
{
|
||||
snprintf (string, length, "%s.%s",
|
||||
@@ -114,7 +114,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
/* create directories in WeeChat home */
|
||||
weechat_mkdir_home (weechat_plugin->name, 0755);
|
||||
length = strlen (weechat_plugin->name) + strlen ("/autoload") + 1;
|
||||
string = (char *)malloc (length * sizeof (char));
|
||||
string = malloc (length);
|
||||
if (string)
|
||||
{
|
||||
snprintf (string, length, "%s/autoload", weechat_plugin->name);
|
||||
@@ -124,7 +124,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
|
||||
/* add command */
|
||||
length = strlen (completion) + strlen (weechat_plugin->name) + 16;
|
||||
string = (char *)malloc (length * sizeof (char));
|
||||
string = malloc (length);
|
||||
if (string)
|
||||
{
|
||||
snprintf (string, length, "%s|%%(%s_script)",
|
||||
@@ -146,7 +146,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
|
||||
/* add completion */
|
||||
length = strlen (weechat_plugin->name) + 16;
|
||||
string = (char *)malloc (length * sizeof (char));
|
||||
string = malloc (length);
|
||||
if (string)
|
||||
{
|
||||
snprintf (string, length, "%s_script", weechat_plugin->name);
|
||||
@@ -214,7 +214,7 @@ script_auto_load (struct t_weechat_plugin *weechat_plugin,
|
||||
if (!dir_home)
|
||||
return;
|
||||
dir_length = strlen (dir_home) + strlen (weechat_plugin->name) + 16;
|
||||
dir_name = (char *)malloc (dir_length * sizeof (char));
|
||||
dir_name = malloc (dir_length);
|
||||
if (!dir_name)
|
||||
return;
|
||||
|
||||
@@ -264,7 +264,7 @@ script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
||||
if (!dir_home)
|
||||
return NULL;
|
||||
length = strlen (dir_home) + strlen (filename + 1) + 1;
|
||||
final_name = (char *)malloc (length * sizeof (char));
|
||||
final_name = malloc (length);
|
||||
if (final_name)
|
||||
{
|
||||
snprintf (final_name, length, "%s%s", dir_home, filename + 1);
|
||||
@@ -279,7 +279,7 @@ script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
||||
/* try WeeChat user's autoload dir */
|
||||
length = strlen (dir_home) + strlen (weechat_plugin->name) + 8 +
|
||||
strlen (filename) + 16;
|
||||
final_name = (char *)malloc (length * sizeof (char));
|
||||
final_name = malloc (length);
|
||||
if (final_name)
|
||||
{
|
||||
snprintf (final_name, length,
|
||||
@@ -293,7 +293,7 @@ script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
||||
/* try WeeChat language user's dir */
|
||||
length = strlen (dir_home) + strlen (weechat_plugin->name) +
|
||||
strlen (filename) + 16;
|
||||
final_name = (char *)malloc (length * sizeof (char));
|
||||
final_name = malloc (length);
|
||||
if (final_name)
|
||||
{
|
||||
snprintf (final_name, length,
|
||||
@@ -305,7 +305,7 @@ script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
||||
|
||||
/* try WeeChat user's dir */
|
||||
length = strlen (dir_home) + strlen (filename) + 16;
|
||||
final_name = (char *)malloc (length * sizeof (char));
|
||||
final_name = malloc (length);
|
||||
if (final_name)
|
||||
{
|
||||
snprintf (final_name, length,
|
||||
@@ -322,7 +322,7 @@ script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
||||
{
|
||||
length = strlen (dir_system) + strlen (weechat_plugin->name) +
|
||||
strlen (filename) + 16;
|
||||
final_name = (char *)malloc (length * sizeof (char));
|
||||
final_name = malloc (length);
|
||||
if (final_name)
|
||||
{
|
||||
snprintf (final_name,length,
|
||||
@@ -369,7 +369,7 @@ script_add (struct t_weechat_plugin *weechat_plugin,
|
||||
license, name, weechat_plugin->license);
|
||||
}
|
||||
|
||||
new_script = (struct t_plugin_script *)malloc (sizeof (struct t_plugin_script));
|
||||
new_script = malloc (sizeof (*new_script));
|
||||
if (new_script)
|
||||
{
|
||||
new_script->filename = strdup (filename);
|
||||
|
||||
Reference in New Issue
Block a user