Skip to content

Commit

Permalink
Merge tag 'gcc-plugins-v4.12-rc4' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/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
  • Loading branch information
Linus Torvalds committed Jun 1, 2017
2 parents 9ea15a5 + 243dd05 commit 2f48641
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 60 deletions.
10 changes: 5 additions & 5 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
amdgpu_vram_mgr_init,
amdgpu_vram_mgr_fini,
amdgpu_vram_mgr_new,
amdgpu_vram_mgr_del,
amdgpu_vram_mgr_debug
.init = amdgpu_vram_mgr_init,
.takedown = amdgpu_vram_mgr_fini,
.get_node = amdgpu_vram_mgr_new,
.put_node = amdgpu_vram_mgr_del,
.debug = amdgpu_vram_mgr_debug
};
20 changes: 10 additions & 10 deletions drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,17 +709,17 @@ static int tf_vega10_thermal_disable_alert(struct pp_hwmgr *hwmgr,

static struct phm_master_table_item
vega10_thermal_start_thermal_controller_master_list[] = {
{NULL, tf_vega10_thermal_initialize},
{NULL, tf_vega10_thermal_set_temperature_range},
{NULL, tf_vega10_thermal_enable_alert},
{ .tableFunction = tf_vega10_thermal_initialize },
{ .tableFunction = tf_vega10_thermal_set_temperature_range },
{ .tableFunction = tf_vega10_thermal_enable_alert },
/* 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
* so it would be pointless.
* If this assumption changes we have to revisit this table.
*/
{NULL, tf_vega10_thermal_setup_fan_table},
{NULL, tf_vega10_thermal_start_smc_fan_control},
{NULL, NULL}
{ .tableFunction = tf_vega10_thermal_setup_fan_table },
{ .tableFunction = tf_vega10_thermal_start_smc_fan_control },
{ }
};

static struct phm_master_table_header
Expand All @@ -731,10 +731,10 @@ vega10_thermal_start_thermal_controller_master = {

static struct phm_master_table_item
vega10_thermal_set_temperature_range_master_list[] = {
{NULL, tf_vega10_thermal_disable_alert},
{NULL, tf_vega10_thermal_set_temperature_range},
{NULL, tf_vega10_thermal_enable_alert},
{NULL, NULL}
{ .tableFunction = tf_vega10_thermal_disable_alert },
{ .tableFunction = tf_vega10_thermal_set_temperature_range },
{ .tableFunction = tf_vega10_thermal_enable_alert },
{ }
};

struct phm_master_table_header
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,10 @@ static int vdec_h264_get_param(unsigned long h_vdec,
}

static struct vdec_common_if vdec_h264_if = {
vdec_h264_init,
vdec_h264_decode,
vdec_h264_get_param,
vdec_h264_deinit,
.init = vdec_h264_init,
.decode = vdec_h264_decode,
.get_param = vdec_h264_get_param,
.deinit = vdec_h264_deinit,
};

struct vdec_common_if *get_h264_dec_comm_if(void);
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,10 @@ static void vdec_vp8_deinit(unsigned long h_vdec)
}

static struct vdec_common_if vdec_vp8_if = {
vdec_vp8_init,
vdec_vp8_decode,
vdec_vp8_get_param,
vdec_vp8_deinit,
.init = vdec_vp8_init,
.decode = vdec_vp8_decode,
.get_param = vdec_vp8_get_param,
.deinit = vdec_vp8_deinit,
};

struct vdec_common_if *get_vp8_dec_comm_if(void);
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,10 +979,10 @@ static int vdec_vp9_get_param(unsigned long h_vdec,
}

static struct vdec_common_if vdec_vp9_if = {
vdec_vp9_init,
vdec_vp9_decode,
vdec_vp9_get_param,
vdec_vp9_deinit,
.init = vdec_vp9_init,
.decode = vdec_vp9_decode,
.get_param = vdec_vp9_get_param,
.deinit = vdec_vp9_deinit,
};

struct vdec_common_if *get_vp9_dec_comm_if(void);
Expand Down
12 changes: 11 additions & 1 deletion drivers/misc/sgi-xp/xp.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ static inline enum xp_retval
xpc_send(short partid, int ch_number, u32 flags, void *payload,
u16 payload_size)
{
if (!xpc_interface.send)
return xpNotLoaded;

return xpc_interface.send(partid, ch_number, flags, payload,
payload_size);
}
Expand All @@ -317,19 +320,26 @@ static inline enum xp_retval
xpc_send_notify(short partid, int ch_number, u32 flags, void *payload,
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,
payload_size, func, key);
}

static inline void
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
xpc_partid_to_nasids(short partid, void *nasids)
{
if (!xpc_interface.partid_to_nasids)
return xpNotLoaded;

return xpc_interface.partid_to_nasids(partid, nasids);
}

Expand Down
36 changes: 7 additions & 29 deletions drivers/misc/sgi-xp/xp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,9 @@ struct xpc_registration xpc_registrations[XPC_MAX_NCHANNELS];
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
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
};
struct xpc_interface xpc_interface = { };
EXPORT_SYMBOL_GPL(xpc_interface);

/*
Expand Down Expand Up @@ -115,17 +101,7 @@ EXPORT_SYMBOL_GPL(xpc_set_interface);
void
xpc_clear_interface(void)
{
xpc_interface.connect = (void (*)(int))xpc_notloaded;
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;
memset(&xpc_interface, 0, sizeof(xpc_interface));
}
EXPORT_SYMBOL_GPL(xpc_clear_interface);

Expand Down Expand Up @@ -188,7 +164,8 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size,

mutex_unlock(&registration->mutex);

xpc_interface.connect(ch_number);
if (xpc_interface.connect)
xpc_interface.connect(ch_number);

return xpSuccess;
}
Expand Down Expand Up @@ -237,7 +214,8 @@ xpc_disconnect(int ch_number)
registration->assigned_limit = 0;
registration->idle_limit = 0;

xpc_interface.disconnect(ch_number);
if (xpc_interface.disconnect)
xpc_interface.disconnect(ch_number);

mutex_unlock(&registration->mutex);

Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ struct vfsmount *nfs_do_submount(struct dentry *dentry, struct nfs_fh *fh,

devname = nfs_devname(dentry, page, PAGE_SIZE);
if (IS_ERR(devname))
mnt = (struct vfsmount *)devname;
mnt = ERR_CAST(devname);
else
mnt = nfs_do_clone_mount(NFS_SB(dentry->d_sb), devname, &mountdata);

Expand Down
2 changes: 1 addition & 1 deletion fs/ntfs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
PTR_ERR(dent_inode));
kfree(name);
/* 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. */
if (MREF_ERR(mref) == -ENOENT) {
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,

if (IS_ERR(inode)) {
mlog_errno(PTR_ERR(inode));
result = (void *)inode;
result = ERR_CAST(inode);
goto bail;
}

Expand Down

0 comments on commit 2f48641

Please sign in to comment.