Skip to content

Commit

Permalink
pythongh-125517: Fix unreachable code warnings in _testembed.c (pyt…
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Oct 15, 2024
1 parent cc5a225 commit c8a1818
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
16 changes: 10 additions & 6 deletions Doc/c-api/init_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1825,14 +1825,18 @@ return ``-1`` on error:
PyInitConfig_Free(config);
return 0;
// Display the error message
const char *err_msg;
error:
(void)PyInitConfig_GetError(config, &err_msg);
printf("PYTHON INIT ERROR: %s\n", err_msg);
PyInitConfig_Free(config);
{
// Display the error message
// This uncommon braces style is used, because you cannot make
// goto targets point to variable declarations.
const char *err_msg;
(void)PyInitConfig_GetError(config, &err_msg);
printf("PYTHON INIT ERROR: %s\n", err_msg);
PyInitConfig_Free(config);
return -1;
return -1;
}
}
Expand Down
20 changes: 12 additions & 8 deletions Programs/_testembed.c
Original file line number Diff line number Diff line change
Expand Up @@ -1902,11 +1902,13 @@ static int test_initconfig_api(void)
Py_Finalize();
return 0;

const char *err_msg;
error:
(void)PyInitConfig_GetError(config, &err_msg);
printf("Python init failed: %s\n", err_msg);
exit(1);
{
const char *err_msg;
(void)PyInitConfig_GetError(config, &err_msg);
printf("Python init failed: %s\n", err_msg);
exit(1);
}
}


Expand Down Expand Up @@ -2050,11 +2052,13 @@ static int test_initconfig_module(void)
Py_Finalize();
return 0;

const char *err_msg;
error:
(void)PyInitConfig_GetError(config, &err_msg);
printf("Python init failed: %s\n", err_msg);
exit(1);
{
const char *err_msg;
(void)PyInitConfig_GetError(config, &err_msg);
printf("Python init failed: %s\n", err_msg);
exit(1);
}
}


Expand Down

0 comments on commit c8a1818

Please sign in to comment.