Skip to content

Commit

Permalink
fbdev: Move fbdev drivers from strlcpy to strscpy
Browse files Browse the repository at this point in the history
Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Helge Deller <deller@gmx.de>
  • Loading branch information
Wolfram Sang authored and hdeller committed Aug 24, 2022
1 parent 144c467 commit 8d02685
Show file tree
Hide file tree
Showing 29 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion drivers/video/console/sticore.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ static char default_sti_path[21] __read_mostly;
static int __init sti_setup(char *str)
{
if (str)
strlcpy (default_sti_path, str, sizeof (default_sti_path));
strscpy(default_sti_path, str, sizeof(default_sti_path));

return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/aty/atyfb_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -3891,7 +3891,7 @@ static int __init atyfb_setup(char *options)
&& (!strncmp(this_opt, "Mach64:", 7))) {
static unsigned char m64_num;
static char mach64_str[80];
strlcpy(mach64_str, this_opt + 7, sizeof(mach64_str));
strscpy(mach64_str, this_opt + 7, sizeof(mach64_str));
if (!store_video_par(mach64_str, m64_num)) {
m64_num++;
mach64_count = m64_num;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/aty/radeon_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1980,7 +1980,7 @@ static int radeon_set_fbinfo(struct radeonfb_info *rinfo)
info->screen_base = rinfo->fb_base;
info->screen_size = rinfo->mapped_vram;
/* Fill fix common fields */
strlcpy(info->fix.id, rinfo->name, sizeof(info->fix.id));
strscpy(info->fix.id, rinfo->name, sizeof(info->fix.id));
info->fix.smem_start = rinfo->fb_base_phys;
info->fix.smem_len = rinfo->video_ram;
info->fix.type = FB_TYPE_PACKED_PIXELS;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/bw2.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static int bw2_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)

static void bw2_init_fix(struct fb_info *info, int linebytes)
{
strlcpy(info->fix.id, "bwtwo", sizeof(info->fix.id));
strscpy(info->fix.id, "bwtwo", sizeof(info->fix.id));

info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.visual = FB_VISUAL_MONO01;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/cirrusfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1999,7 +1999,7 @@ static int cirrusfb_set_fbinfo(struct fb_info *info)
}

/* Fill fix common fields */
strlcpy(info->fix.id, cirrusfb_board_info[cinfo->btype].name,
strscpy(info->fix.id, cirrusfb_board_info[cinfo->btype].name,
sizeof(info->fix.id));

/* monochrome: only 1 memory plane */
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/clps711x-fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ static int clps711x_fb_probe(struct platform_device *pdev)
info->var.vmode = FB_VMODE_NONINTERLACED;
info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.accel = FB_ACCEL_NONE;
strlcpy(info->fix.id, CLPS711X_FB_NAME, sizeof(info->fix.id));
strscpy(info->fix.id, CLPS711X_FB_NAME, sizeof(info->fix.id));
fb_videomode_to_var(&info->var, &cfb->mode);

ret = fb_alloc_cmap(&info->cmap, BIT(CLPS711X_FB_BPP_MAX), 0);
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/core/fbcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ static int __init fb_console_setup(char *this_opt)

while ((options = strsep(&this_opt, ",")) != NULL) {
if (!strncmp(options, "font:", 5)) {
strlcpy(fontname, options + 5, sizeof(fontname));
strscpy(fontname, options + 5, sizeof(fontname));
continue;
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/video/fbdev/cyber2000fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ int cyber2000fb_attach(struct cyberpro_info *info, int idx)
info->fb_size = int_cfb_info->fb.fix.smem_len;
info->info = int_cfb_info;

strlcpy(info->dev_name, int_cfb_info->fb.fix.id,
strscpy(info->dev_name, int_cfb_info->fb.fix.id,
sizeof(info->dev_name));
}

Expand Down Expand Up @@ -1229,7 +1229,7 @@ static int cyber2000fb_ddc_getsda(void *data)

static int cyber2000fb_setup_ddc_bus(struct cfb_info *cfb)
{
strlcpy(cfb->ddc_adapter.name, cfb->fb.fix.id,
strscpy(cfb->ddc_adapter.name, cfb->fb.fix.id,
sizeof(cfb->ddc_adapter.name));
cfb->ddc_adapter.owner = THIS_MODULE;
cfb->ddc_adapter.class = I2C_CLASS_DDC;
Expand Down Expand Up @@ -1304,7 +1304,7 @@ static int cyber2000fb_i2c_getscl(void *data)

static int cyber2000fb_i2c_register(struct cfb_info *cfb)
{
strlcpy(cfb->i2c_adapter.name, cfb->fb.fix.id,
strscpy(cfb->i2c_adapter.name, cfb->fb.fix.id,
sizeof(cfb->i2c_adapter.name));
cfb->i2c_adapter.owner = THIS_MODULE;
cfb->i2c_adapter.algo_data = &cfb->i2c_algo;
Expand Down Expand Up @@ -1500,7 +1500,7 @@ static int cyber2000fb_setup(char *options)
if (strncmp(opt, "font:", 5) == 0) {
static char default_font_storage[40];

strlcpy(default_font_storage, opt + 5,
strscpy(default_font_storage, opt + 5,
sizeof(default_font_storage));
default_font = default_font_storage;
continue;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/ffb.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ static void ffb_init_fix(struct fb_info *info)
} else
ffb_type_name = "Elite 3D";

strlcpy(info->fix.id, ffb_type_name, sizeof(info->fix.id));
strscpy(info->fix.id, ffb_type_name, sizeof(info->fix.id));

info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.visual = FB_VISUAL_TRUECOLOR;
Expand Down
6 changes: 3 additions & 3 deletions drivers/video/fbdev/geode/gx1fb_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,13 @@ static void __init gx1fb_setup(char *options)
continue;

if (!strncmp(this_opt, "mode:", 5))
strlcpy(mode_option, this_opt + 5, sizeof(mode_option));
strscpy(mode_option, this_opt + 5, sizeof(mode_option));
else if (!strncmp(this_opt, "crt:", 4))
crt_option = !!simple_strtoul(this_opt + 4, NULL, 0);
else if (!strncmp(this_opt, "panel:", 6))
strlcpy(panel_option, this_opt + 6, sizeof(panel_option));
strscpy(panel_option, this_opt + 6, sizeof(panel_option));
else
strlcpy(mode_option, this_opt, sizeof(mode_option));
strscpy(mode_option, this_opt, sizeof(mode_option));
}
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/gxt4500.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ static int gxt4500_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
cardtype = ent->driver_data;
par->refclk_ps = cardinfo[cardtype].refclk_ps;
info->fix = gxt4500_fix;
strlcpy(info->fix.id, cardinfo[cardtype].cardname,
strscpy(info->fix.id, cardinfo[cardtype].cardname,
sizeof(info->fix.id));
info->pseudo_palette = par->pseudo_palette;

Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/i740fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static int i740fb_setup_ddc_bus(struct fb_info *info)
{
struct i740fb_par *par = info->par;

strlcpy(par->ddc_adapter.name, info->fix.id,
strscpy(par->ddc_adapter.name, info->fix.id,
sizeof(par->ddc_adapter.name));
par->ddc_adapter.owner = THIS_MODULE;
par->ddc_adapter.class = I2C_CLASS_DDC;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/imxfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ static int imxfb_init_fbinfo(struct platform_device *pdev)

fbi->devtype = pdev->id_entry->driver_data;

strlcpy(info->fix.id, IMX_NAME, sizeof(info->fix.id));
strscpy(info->fix.id, IMX_NAME, sizeof(info->fix.id));

info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.type_aux = 0;
Expand Down
6 changes: 3 additions & 3 deletions drivers/video/fbdev/matrox/matroxfb_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -2383,9 +2383,9 @@ static int __init matroxfb_setup(char *options) {
else if (!strncmp(this_opt, "mem:", 4))
mem = simple_strtoul(this_opt+4, NULL, 0);
else if (!strncmp(this_opt, "mode:", 5))
strlcpy(videomode, this_opt+5, sizeof(videomode));
strscpy(videomode, this_opt + 5, sizeof(videomode));
else if (!strncmp(this_opt, "outputs:", 8))
strlcpy(outputs, this_opt+8, sizeof(outputs));
strscpy(outputs, this_opt + 8, sizeof(outputs));
else if (!strncmp(this_opt, "dfp:", 4)) {
dfp_type = simple_strtoul(this_opt+4, NULL, 0);
dfp = 1;
Expand Down Expand Up @@ -2455,7 +2455,7 @@ static int __init matroxfb_setup(char *options) {
else if (!strcmp(this_opt, "dfp"))
dfp = value;
else {
strlcpy(videomode, this_opt, sizeof(videomode));
strscpy(videomode, this_opt, sizeof(videomode));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/omap2/omapfb/omapfb-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ static void clear_fb_info(struct fb_info *fbi)
{
memset(&fbi->var, 0, sizeof(fbi->var));
memset(&fbi->fix, 0, sizeof(fbi->fix));
strlcpy(fbi->fix.id, MODULE_NAME, sizeof(fbi->fix.id));
strscpy(fbi->fix.id, MODULE_NAME, sizeof(fbi->fix.id));
}

static int omapfb_free_all_fbmem(struct omapfb2_device *fbdev)
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/pxa168fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ static int pxa168fb_probe(struct platform_device *pdev)
info->flags = FBINFO_DEFAULT | FBINFO_PARTIAL_PAN_OK |
FBINFO_HWACCEL_XPAN | FBINFO_HWACCEL_YPAN;
info->node = -1;
strlcpy(info->fix.id, mi->id, 16);
strscpy(info->fix.id, mi->id, 16);
info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.type_aux = 0;
info->fix.xpanstep = 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/pxafb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,7 @@ static int __init pxafb_setup_options(void)
return -ENODEV;

if (options)
strlcpy(g_options, options, sizeof(g_options));
strscpy(g_options, options, sizeof(g_options));

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/s3fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static int s3fb_setup_ddc_bus(struct fb_info *info)
{
struct s3fb_info *par = info->par;

strlcpy(par->ddc_adapter.name, info->fix.id,
strscpy(par->ddc_adapter.name, info->fix.id,
sizeof(par->ddc_adapter.name));
par->ddc_adapter.owner = THIS_MODULE;
par->ddc_adapter.class = I2C_CLASS_DDC;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/simplefb.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static int simplefb_regulators_get(struct simplefb_par *par,
if (!p || p == prop->name)
continue;

strlcpy(name, prop->name,
strscpy(name, prop->name,
strlen(prop->name) - strlen(SUPPLY_SUFFIX) + 1);
regulator = devm_regulator_get_optional(&pdev->dev, name);
if (IS_ERR(regulator)) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/video/fbdev/sis/sis_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1872,7 +1872,7 @@ sisfb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info)

memset(fix, 0, sizeof(struct fb_fix_screeninfo));

strlcpy(fix->id, ivideo->myid, sizeof(fix->id));
strscpy(fix->id, ivideo->myid, sizeof(fix->id));

mutex_lock(&info->mm_lock);
fix->smem_start = ivideo->video_base + ivideo->video_offset;
Expand Down Expand Up @@ -5879,7 +5879,7 @@ static int sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
ivideo->cardnumber++;
}

strlcpy(ivideo->myid, chipinfo->chip_name, sizeof(ivideo->myid));
strscpy(ivideo->myid, chipinfo->chip_name, sizeof(ivideo->myid));

ivideo->warncount = 0;
ivideo->chip_id = pdev->device;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/sm501fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ static int sm501fb_init_fb(struct fb_info *fb, enum sm501_controller head,
enable = 0;
}

strlcpy(fb->fix.id, fbname, sizeof(fb->fix.id));
strscpy(fb->fix.id, fbname, sizeof(fb->fix.id));

memcpy(&par->ops,
(head == HEAD_CRT) ? &sm501fb_ops_crt : &sm501fb_ops_pnl,
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/sstfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ static int sstfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto fail;
}
sst_get_memsize(info, &fix->smem_len);
strlcpy(fix->id, spec->name, sizeof(fix->id));
strscpy(fix->id, spec->name, sizeof(fix->id));

printk(KERN_INFO "%s (revision %d) with %s dac\n",
fix->id, par->revision, par->dac_sw.name);
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/sunxvr1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static int gfb_set_fbinfo(struct gfb_info *gp)
info->pseudo_palette = gp->pseudo_palette;

/* Fill fix common fields */
strlcpy(info->fix.id, "gfb", sizeof(info->fix.id));
strscpy(info->fix.id, "gfb", sizeof(info->fix.id));
info->fix.smem_start = gp->fb_base_phys;
info->fix.smem_len = gp->fb_size;
info->fix.type = FB_TYPE_PACKED_PIXELS;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/sunxvr2500.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static int s3d_set_fbinfo(struct s3d_info *sp)
info->pseudo_palette = sp->pseudo_palette;

/* Fill fix common fields */
strlcpy(info->fix.id, "s3d", sizeof(info->fix.id));
strscpy(info->fix.id, "s3d", sizeof(info->fix.id));
info->fix.smem_start = sp->fb_base_phys;
info->fix.smem_len = sp->fb_size;
info->fix.type = FB_TYPE_PACKED_PIXELS;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/sunxvr500.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static int e3d_set_fbinfo(struct e3d_info *ep)
info->pseudo_palette = ep->pseudo_palette;

/* Fill fix common fields */
strlcpy(info->fix.id, "e3d", sizeof(info->fix.id));
strscpy(info->fix.id, "e3d", sizeof(info->fix.id));
info->fix.smem_start = ep->fb_base_phys;
info->fix.smem_len = ep->fb_size;
info->fix.type = FB_TYPE_PACKED_PIXELS;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/tcx.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ tcx_init_fix(struct fb_info *info, int linebytes)
else
tcx_name = "TCX24";

strlcpy(info->fix.id, tcx_name, sizeof(info->fix.id));
strscpy(info->fix.id, tcx_name, sizeof(info->fix.id));

info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
Expand Down
4 changes: 2 additions & 2 deletions drivers/video/fbdev/tdfxfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ static int tdfxfb_setup_ddc_bus(struct tdfxfb_i2c_chan *chan, const char *name,
{
int rc;

strlcpy(chan->adapter.name, name, sizeof(chan->adapter.name));
strscpy(chan->adapter.name, name, sizeof(chan->adapter.name));
chan->adapter.owner = THIS_MODULE;
chan->adapter.class = I2C_CLASS_DDC;
chan->adapter.algo_data = &chan->algo;
Expand Down Expand Up @@ -1293,7 +1293,7 @@ static int tdfxfb_setup_i2c_bus(struct tdfxfb_i2c_chan *chan, const char *name,
{
int rc;

strlcpy(chan->adapter.name, name, sizeof(chan->adapter.name));
strscpy(chan->adapter.name, name, sizeof(chan->adapter.name));
chan->adapter.owner = THIS_MODULE;
chan->adapter.algo_data = &chan->algo;
chan->adapter.dev.parent = dev;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/tgafb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ tgafb_init_fix(struct fb_info *info)
memory_size = 16777216;
}

strlcpy(info->fix.id, tga_type_name, sizeof(info->fix.id));
strscpy(info->fix.id, tga_type_name, sizeof(info->fix.id));

info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.type_aux = 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fbdev/tridentfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ static int tridentfb_setup_ddc_bus(struct fb_info *info)
{
struct tridentfb_par *par = info->par;

strlcpy(par->ddc_adapter.name, info->fix.id,
strscpy(par->ddc_adapter.name, info->fix.id,
sizeof(par->ddc_adapter.name));
par->ddc_adapter.owner = THIS_MODULE;
par->ddc_adapter.class = I2C_CLASS_DDC;
Expand Down

0 comments on commit 8d02685

Please sign in to comment.