Skip to content

Commit 7b24ce0

Browse files
committed
patch 8.0.1654: warnings for conversion of void to function pointer
Problem: Warnings for conversion of void to function pointer. Solution: Use a temp variable that is a function pointer.
1 parent 1834d37 commit 7b24ce0

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

src/if_python.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ end_dynamic_python(void)
672672
python_runtime_link_init(char *libname, int verbose)
673673
{
674674
int i;
675-
void *ucs_as_encoded_string;
675+
PYTHON_PROC *ucs_as_encoded_string =
676+
(PYTHON_PROC*)&py_PyUnicode_AsEncodedString;
676677

677678
#if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON3)
678679
/* Can't have Python and Python3 loaded at the same time.
@@ -711,14 +712,12 @@ python_runtime_link_init(char *libname, int verbose)
711712

712713
/* Load unicode functions separately as only the ucs2 or the ucs4 functions
713714
* will be present in the library. */
714-
ucs_as_encoded_string = symbol_from_dll(hinstPython,
715+
*ucs_as_encoded_string = symbol_from_dll(hinstPython,
715716
"PyUnicodeUCS2_AsEncodedString");
716-
if (ucs_as_encoded_string == NULL)
717-
ucs_as_encoded_string = symbol_from_dll(hinstPython,
717+
if (*ucs_as_encoded_string == NULL)
718+
*ucs_as_encoded_string = symbol_from_dll(hinstPython,
718719
"PyUnicodeUCS4_AsEncodedString");
719-
if (ucs_as_encoded_string != NULL)
720-
py_PyUnicode_AsEncodedString = ucs_as_encoded_string;
721-
else
720+
if (*ucs_as_encoded_string == NULL)
722721
{
723722
close_dll(hinstPython);
724723
hinstPython = 0;

src/if_python3.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,10 @@ end_dynamic_python3(void)
600600
py3_runtime_link_init(char *libname, int verbose)
601601
{
602602
int i;
603-
void *ucs_from_string, *ucs_decode, *ucs_as_encoded_string;
603+
PYTHON_PROC *ucs_from_string = (PYTHON_PROC *)&py3_PyUnicode_FromString;
604+
PYTHON_PROC *ucs_decode = (PYTHON_PROC *)&py3_PyUnicode_Decode;
605+
PYTHON_PROC *ucs_as_encoded_string =
606+
(PYTHON_PROC *)&py3_PyUnicode_AsEncodedString;
604607

605608
# if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON)
606609
/* Can't have Python and Python3 loaded at the same time.
@@ -641,33 +644,29 @@ py3_runtime_link_init(char *libname, int verbose)
641644
/* Load unicode functions separately as only the ucs2 or the ucs4 functions
642645
* will be present in the library. */
643646
# if PY_VERSION_HEX >= 0x030300f0
644-
ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicode_FromString");
645-
ucs_decode = symbol_from_dll(hinstPy3, "PyUnicode_Decode");
646-
ucs_as_encoded_string = symbol_from_dll(hinstPy3,
647+
*ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicode_FromString");
648+
*ucs_decode = symbol_from_dll(hinstPy3, "PyUnicode_Decode");
649+
*ucs_as_encoded_string = symbol_from_dll(hinstPy3,
647650
"PyUnicode_AsEncodedString");
648651
# else
649-
ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicodeUCS2_FromString");
650-
ucs_decode = symbol_from_dll(hinstPy3,
652+
*ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicodeUCS2_FromString");
653+
*ucs_decode = symbol_from_dll(hinstPy3,
651654
"PyUnicodeUCS2_Decode");
652-
ucs_as_encoded_string = symbol_from_dll(hinstPy3,
655+
*ucs_as_encoded_string = symbol_from_dll(hinstPy3,
653656
"PyUnicodeUCS2_AsEncodedString");
654-
if (!ucs_from_string || !ucs_decode || !ucs_as_encoded_string)
657+
if (*ucs_from_string == NULL || *ucs_decode == NULL
658+
|| *ucs_as_encoded_string == NULL)
655659
{
656-
ucs_from_string = symbol_from_dll(hinstPy3,
660+
*ucs_from_string = symbol_from_dll(hinstPy3,
657661
"PyUnicodeUCS4_FromString");
658-
ucs_decode = symbol_from_dll(hinstPy3,
662+
*ucs_decode = symbol_from_dll(hinstPy3,
659663
"PyUnicodeUCS4_Decode");
660-
ucs_as_encoded_string = symbol_from_dll(hinstPy3,
664+
*ucs_as_encoded_string = symbol_from_dll(hinstPy3,
661665
"PyUnicodeUCS4_AsEncodedString");
662666
}
663667
# endif
664-
if (ucs_from_string && ucs_decode && ucs_as_encoded_string)
665-
{
666-
py3_PyUnicode_FromString = ucs_from_string;
667-
py3_PyUnicode_Decode = ucs_decode;
668-
py3_PyUnicode_AsEncodedString = ucs_as_encoded_string;
669-
}
670-
else
668+
if (*ucs_from_string == NULL || *ucs_decode == NULL
669+
|| *ucs_as_encoded_string == NULL)
671670
{
672671
close_dll(hinstPy3);
673672
hinstPy3 = 0;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ static char *(features[]) =
762762

763763
static int included_patches[] =
764764
{ /* Add new patch number below this line */
765+
/**/
766+
1654,
765767
/**/
766768
1653,
767769
/**/

0 commit comments

Comments
 (0)