提交 2f48641c 编写于 作者: L Linus Torvalds

Merge tag 'gcc-plugins-v4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull gcc-plugin prepwork from Kees Cook:
 "Use designated initializers for mtk-vcodec, powerplay, amdgpu, and
  sgi-xp. Use ERR_CAST() to avoid cross-structure cast in ocf2, ntfs,
  and NFS.

  Christoph Hellwig recommended that I send these fixes now, rather than
  waiting for the v4.13 merge window. These are all initializer and cast
  fixes needed for the future randstruct plugin that haven't been picked
  up by the respective maintainers"

* tag 'gcc-plugins-v4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  mtk-vcodec: Use designated initializers
  drm/amd/powerplay: Use designated initializers
  drm/amdgpu: Use designated initializers
  sgi-xp: Use designated initializers
  ocfs2: Use ERR_CAST() to avoid cross-structure cast
  ntfs: Use ERR_CAST() to avoid cross-structure cast
  NFS: Use ERR_CAST() to avoid cross-structure cast
...@@ -220,9 +220,9 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man, ...@@ -220,9 +220,9 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,
} }
const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = { const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = {
amdgpu_vram_mgr_init, .init = amdgpu_vram_mgr_init,
amdgpu_vram_mgr_fini, .takedown = amdgpu_vram_mgr_fini,
amdgpu_vram_mgr_new, .get_node = amdgpu_vram_mgr_new,
amdgpu_vram_mgr_del, .put_node = amdgpu_vram_mgr_del,
amdgpu_vram_mgr_debug .debug = amdgpu_vram_mgr_debug
}; };
...@@ -709,17 +709,17 @@ static int tf_vega10_thermal_disable_alert(struct pp_hwmgr *hwmgr, ...@@ -709,17 +709,17 @@ static int tf_vega10_thermal_disable_alert(struct pp_hwmgr *hwmgr,
static struct phm_master_table_item static struct phm_master_table_item
vega10_thermal_start_thermal_controller_master_list[] = { vega10_thermal_start_thermal_controller_master_list[] = {
{NULL, tf_vega10_thermal_initialize}, { .tableFunction = tf_vega10_thermal_initialize },
{NULL, tf_vega10_thermal_set_temperature_range}, { .tableFunction = tf_vega10_thermal_set_temperature_range },
{NULL, tf_vega10_thermal_enable_alert}, { .tableFunction = tf_vega10_thermal_enable_alert },
/* We should restrict performance levels to low before we halt the SMC. /* We should restrict performance levels to low before we halt the SMC.
* On the other hand we are still in boot state when we do this * On the other hand we are still in boot state when we do this
* so it would be pointless. * so it would be pointless.
* If this assumption changes we have to revisit this table. * If this assumption changes we have to revisit this table.
*/ */
{NULL, tf_vega10_thermal_setup_fan_table}, { .tableFunction = tf_vega10_thermal_setup_fan_table },
{NULL, tf_vega10_thermal_start_smc_fan_control}, { .tableFunction = tf_vega10_thermal_start_smc_fan_control },
{NULL, NULL} { }
}; };
static struct phm_master_table_header static struct phm_master_table_header
...@@ -731,10 +731,10 @@ vega10_thermal_start_thermal_controller_master = { ...@@ -731,10 +731,10 @@ vega10_thermal_start_thermal_controller_master = {
static struct phm_master_table_item static struct phm_master_table_item
vega10_thermal_set_temperature_range_master_list[] = { vega10_thermal_set_temperature_range_master_list[] = {
{NULL, tf_vega10_thermal_disable_alert}, { .tableFunction = tf_vega10_thermal_disable_alert },
{NULL, tf_vega10_thermal_set_temperature_range}, { .tableFunction = tf_vega10_thermal_set_temperature_range },
{NULL, tf_vega10_thermal_enable_alert}, { .tableFunction = tf_vega10_thermal_enable_alert },
{NULL, NULL} { }
}; };
struct phm_master_table_header struct phm_master_table_header
......
...@@ -493,10 +493,10 @@ static int vdec_h264_get_param(unsigned long h_vdec, ...@@ -493,10 +493,10 @@ static int vdec_h264_get_param(unsigned long h_vdec,
} }
static struct vdec_common_if vdec_h264_if = { static struct vdec_common_if vdec_h264_if = {
vdec_h264_init, .init = vdec_h264_init,
vdec_h264_decode, .decode = vdec_h264_decode,
vdec_h264_get_param, .get_param = vdec_h264_get_param,
vdec_h264_deinit, .deinit = vdec_h264_deinit,
}; };
struct vdec_common_if *get_h264_dec_comm_if(void); struct vdec_common_if *get_h264_dec_comm_if(void);
......
...@@ -620,10 +620,10 @@ static void vdec_vp8_deinit(unsigned long h_vdec) ...@@ -620,10 +620,10 @@ static void vdec_vp8_deinit(unsigned long h_vdec)
} }
static struct vdec_common_if vdec_vp8_if = { static struct vdec_common_if vdec_vp8_if = {
vdec_vp8_init, .init = vdec_vp8_init,
vdec_vp8_decode, .decode = vdec_vp8_decode,
vdec_vp8_get_param, .get_param = vdec_vp8_get_param,
vdec_vp8_deinit, .deinit = vdec_vp8_deinit,
}; };
struct vdec_common_if *get_vp8_dec_comm_if(void); struct vdec_common_if *get_vp8_dec_comm_if(void);
......
...@@ -979,10 +979,10 @@ static int vdec_vp9_get_param(unsigned long h_vdec, ...@@ -979,10 +979,10 @@ static int vdec_vp9_get_param(unsigned long h_vdec,
} }
static struct vdec_common_if vdec_vp9_if = { static struct vdec_common_if vdec_vp9_if = {
vdec_vp9_init, .init = vdec_vp9_init,
vdec_vp9_decode, .decode = vdec_vp9_decode,
vdec_vp9_get_param, .get_param = vdec_vp9_get_param,
vdec_vp9_deinit, .deinit = vdec_vp9_deinit,
}; };
struct vdec_common_if *get_vp9_dec_comm_if(void); struct vdec_common_if *get_vp9_dec_comm_if(void);
......
...@@ -309,6 +309,9 @@ static inline enum xp_retval ...@@ -309,6 +309,9 @@ static inline enum xp_retval
xpc_send(short partid, int ch_number, u32 flags, void *payload, xpc_send(short partid, int ch_number, u32 flags, void *payload,
u16 payload_size) u16 payload_size)
{ {
if (!xpc_interface.send)
return xpNotLoaded;
return xpc_interface.send(partid, ch_number, flags, payload, return xpc_interface.send(partid, ch_number, flags, payload,
payload_size); payload_size);
} }
...@@ -317,6 +320,9 @@ static inline enum xp_retval ...@@ -317,6 +320,9 @@ static inline enum xp_retval
xpc_send_notify(short partid, int ch_number, u32 flags, void *payload, xpc_send_notify(short partid, int ch_number, u32 flags, void *payload,
u16 payload_size, xpc_notify_func func, void *key) u16 payload_size, xpc_notify_func func, void *key)
{ {
if (!xpc_interface.send_notify)
return xpNotLoaded;
return xpc_interface.send_notify(partid, ch_number, flags, payload, return xpc_interface.send_notify(partid, ch_number, flags, payload,
payload_size, func, key); payload_size, func, key);
} }
...@@ -324,12 +330,16 @@ xpc_send_notify(short partid, int ch_number, u32 flags, void *payload, ...@@ -324,12 +330,16 @@ xpc_send_notify(short partid, int ch_number, u32 flags, void *payload,
static inline void static inline void
xpc_received(short partid, int ch_number, void *payload) xpc_received(short partid, int ch_number, void *payload)
{ {
return xpc_interface.received(partid, ch_number, payload); if (xpc_interface.received)
xpc_interface.received(partid, ch_number, payload);
} }
static inline enum xp_retval static inline enum xp_retval
xpc_partid_to_nasids(short partid, void *nasids) xpc_partid_to_nasids(short partid, void *nasids)
{ {
if (!xpc_interface.partid_to_nasids)
return xpNotLoaded;
return xpc_interface.partid_to_nasids(partid, nasids); return xpc_interface.partid_to_nasids(partid, nasids);
} }
......
...@@ -69,23 +69,9 @@ struct xpc_registration xpc_registrations[XPC_MAX_NCHANNELS]; ...@@ -69,23 +69,9 @@ struct xpc_registration xpc_registrations[XPC_MAX_NCHANNELS];
EXPORT_SYMBOL_GPL(xpc_registrations); EXPORT_SYMBOL_GPL(xpc_registrations);
/* /*
* Initialize the XPC interface to indicate that XPC isn't loaded. * Initialize the XPC interface to NULL to indicate that XPC isn't loaded.
*/ */
static enum xp_retval struct xpc_interface xpc_interface = { };
xpc_notloaded(void)
{
return xpNotLoaded;
}
struct xpc_interface xpc_interface = {
(void (*)(int))xpc_notloaded,
(void (*)(int))xpc_notloaded,
(enum xp_retval(*)(short, int, u32, void *, u16))xpc_notloaded,
(enum xp_retval(*)(short, int, u32, void *, u16, xpc_notify_func,
void *))xpc_notloaded,
(void (*)(short, int, void *))xpc_notloaded,
(enum xp_retval(*)(short, void *))xpc_notloaded
};
EXPORT_SYMBOL_GPL(xpc_interface); EXPORT_SYMBOL_GPL(xpc_interface);
/* /*
...@@ -115,17 +101,7 @@ EXPORT_SYMBOL_GPL(xpc_set_interface); ...@@ -115,17 +101,7 @@ EXPORT_SYMBOL_GPL(xpc_set_interface);
void void
xpc_clear_interface(void) xpc_clear_interface(void)
{ {
xpc_interface.connect = (void (*)(int))xpc_notloaded; memset(&xpc_interface, 0, sizeof(xpc_interface));
xpc_interface.disconnect = (void (*)(int))xpc_notloaded;
xpc_interface.send = (enum xp_retval(*)(short, int, u32, void *, u16))
xpc_notloaded;
xpc_interface.send_notify = (enum xp_retval(*)(short, int, u32, void *,
u16, xpc_notify_func,
void *))xpc_notloaded;
xpc_interface.received = (void (*)(short, int, void *))
xpc_notloaded;
xpc_interface.partid_to_nasids = (enum xp_retval(*)(short, void *))
xpc_notloaded;
} }
EXPORT_SYMBOL_GPL(xpc_clear_interface); EXPORT_SYMBOL_GPL(xpc_clear_interface);
...@@ -188,7 +164,8 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size, ...@@ -188,7 +164,8 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size,
mutex_unlock(&registration->mutex); mutex_unlock(&registration->mutex);
xpc_interface.connect(ch_number); if (xpc_interface.connect)
xpc_interface.connect(ch_number);
return xpSuccess; return xpSuccess;
} }
...@@ -237,7 +214,8 @@ xpc_disconnect(int ch_number) ...@@ -237,7 +214,8 @@ xpc_disconnect(int ch_number)
registration->assigned_limit = 0; registration->assigned_limit = 0;
registration->idle_limit = 0; registration->idle_limit = 0;
xpc_interface.disconnect(ch_number); if (xpc_interface.disconnect)
xpc_interface.disconnect(ch_number);
mutex_unlock(&registration->mutex); mutex_unlock(&registration->mutex);
......
...@@ -246,7 +246,7 @@ struct vfsmount *nfs_do_submount(struct dentry *dentry, struct nfs_fh *fh, ...@@ -246,7 +246,7 @@ struct vfsmount *nfs_do_submount(struct dentry *dentry, struct nfs_fh *fh,
devname = nfs_devname(dentry, page, PAGE_SIZE); devname = nfs_devname(dentry, page, PAGE_SIZE);
if (IS_ERR(devname)) if (IS_ERR(devname))
mnt = (struct vfsmount *)devname; mnt = ERR_CAST(devname);
else else
mnt = nfs_do_clone_mount(NFS_SB(dentry->d_sb), devname, &mountdata); mnt = nfs_do_clone_mount(NFS_SB(dentry->d_sb), devname, &mountdata);
......
...@@ -159,7 +159,7 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent, ...@@ -159,7 +159,7 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
PTR_ERR(dent_inode)); PTR_ERR(dent_inode));
kfree(name); kfree(name);
/* Return the error code. */ /* Return the error code. */
return (struct dentry *)dent_inode; return ERR_CAST(dent_inode);
} }
/* It is guaranteed that @name is no longer allocated at this point. */ /* It is guaranteed that @name is no longer allocated at this point. */
if (MREF_ERR(mref) == -ENOENT) { if (MREF_ERR(mref) == -ENOENT) {
......
...@@ -119,7 +119,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, ...@@ -119,7 +119,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
mlog_errno(PTR_ERR(inode)); mlog_errno(PTR_ERR(inode));
result = (void *)inode; result = ERR_CAST(inode);
goto bail; goto bail;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册