Prefer strscpy over strcpy

Jonathan Bergh <[email protected]>
Newsgroups org.kernelnewbies.kernelnewbies
Message-ID <ZRhtdqogfqsh+hd4@HP-ENVY-Notebook>
hi there

So this is a question about the common checkpatch warning I am sure (most)
people have seen when runing checkpatch.pl over kernel code. 

In this particular example "driver_name":
  * In: vme_fake.c:
	static const char driver_name[] = "vme_fake": 

will always fit into vme_bridge->name:
  * In: vme_bridge.h:
	...
	#define VMENAMSIZ 16
	...
	struct vme_bridge {
		...
		char name[VMENAMSIZ];
		...
	}

and yet in the __init function, the code uses:
  * vme_fake.c:
	strcpy(fake_bridge->name, driver_name);

Is it (would not be) correct to use:
  * strscpy(fake_bridge->name, driver_name, sizeof(fake_bridge->name));

I cant see an issue, since driver_name is a const char[] and will always 
fit into fake_bridge->name but I wanted to check whether there might be 
some reason strcpy and not strscpy has been used? 

thanks in advance, 
regards
Jon

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.