Skip to content

bpo-40516: Silence GCC 9 warnings on MacOS Catalina #19925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions Modules/nismodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ nis_cat (PyObject *self, PyObject *args, PyObject *kwdict)
dict = PyDict_New ();
if (dict == NULL)
return NULL;
#pragma GCC diagnostic ignored "-Wcast-function-type"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a preprocessor guard to ensure the pragma is only used with compatible compilers.

cb.foreach = (foreachfunc)nis_foreach;
#pragma GCC diagnostic pop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise

data.dict = dict;
map = nis_mapname (map, &data.fix);
cb.data = (char *)&data;
Expand Down Expand Up @@ -298,11 +300,12 @@ nis_xdr_ypmaplist(XDR *xdrs, nismaplist *objp)
if (!nis_xdr_mapname(xdrs, &objp->map)) {
return (FALSE);
}
#pragma GCC diagnostic ignored "-Wcast-function-type"
if (!xdr_pointer(xdrs, (char **)&objp->next,
sizeof(nismaplist), (xdrproc_t)nis_xdr_ypmaplist))
{
sizeof(nismaplist), (xdrproc_t)nis_xdr_ypmaplist)) {
return (FALSE);
}
#pragma GCC diagnostic pop
return (TRUE);
}

Expand All @@ -324,11 +327,12 @@ nis_xdr_ypresp_maplist(XDR *xdrs, nisresp_maplist *objp)
if (!nis_xdr_ypstat(xdrs, &objp->stat)) {
return (FALSE);
}
#pragma GCC diagnostic ignored "-Wcast-function-type"
if (!xdr_pointer(xdrs, (char **)&objp->maps,
sizeof(nismaplist), (xdrproc_t)nis_xdr_ypmaplist))
{
sizeof(nismaplist), (xdrproc_t)nis_xdr_ypmaplist)){
return (FALSE);
}
#pragma GCC diagnostic pop
return (TRUE);
}

Expand All @@ -340,13 +344,14 @@ nisproc_maplist_2(domainname *argp, CLIENT *clnt)
static nisresp_maplist res;

memset(&res, 0, sizeof(res));
#pragma GCC diagnostic ignored "-Wcast-function-type"
if (clnt_call(clnt, YPPROC_MAPLIST,
(xdrproc_t)nis_xdr_domainname, (caddr_t)argp,
(xdrproc_t)nis_xdr_ypresp_maplist, (caddr_t)&res,
TIMEOUT) != RPC_SUCCESS)
{
TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
#pragma GCC diagnostic pop
return (&res);
}

Expand Down
8 changes: 7 additions & 1 deletion Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3392,12 +3392,15 @@ os_chown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid,
* This is for Mac OS X 10.3, which doesn't have lchown.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #22855 will fix the warnings in posixmodule.c (as a side effect of more interesting changes).

* (But we still have an lchown symbol because of weak-linking.)
* It doesn't have fchownat either. So there's no possibility
* of a graceful failover.
* of a graceful failover. GCC 9 complains about this so we silence his
* warning.
*/
#pragma GCC diagnostic ignored "-Waddress"
if ((!follow_symlinks) && (lchown == NULL)) {
follow_symlinks_specified("chown", follow_symlinks);
return NULL;
}
#pragma GCC diagnostic pop
#endif

if (PySys_Audit("os.chown", "OIIi", path->object, uid, gid,
Expand Down Expand Up @@ -14936,11 +14939,14 @@ INITFUNC(void)
#endif /* HAVE_STATVFS */

# ifdef HAVE_LCHOWN
/* GCC 9 complains about lchown always being defined so silence it here. */
#pragma GCC diagnostic ignored "-Waddress"
if (lchown == NULL) {
if (PyObject_DelAttrString(m, "lchown") == -1) {
return NULL;
}
}
#pragma GCC diagnostic pop
#endif /* HAVE_LCHOWN */


Expand Down