All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: android: ion: Replace strncpy() for stracpy()
@ 2019-09-08  4:34 ` Adam Zerella
  0 siblings, 0 replies; 8+ messages in thread
From: Adam Zerella @ 2019-09-08  4:34 UTC (permalink / raw)
  To: labbott, sumit.semwal
  Cc: gregkh, devel, dri-devel, linaro-mm-sig, linux-kernel, Adam Zerella

Using strncpy() does not always terminate the destination string.
stracpy() is a alternative function that does, by using this new
function we will no longer need to insert a null separator.

Signed-off-by: Adam Zerella <adam.zerella@gmail.com>
---
 drivers/staging/android/ion/ion.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index e6b1ca141b93..17901bd626be 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -433,8 +433,7 @@ static int ion_query_heaps(struct ion_heap_query *query)
 	max_cnt = query->cnt;
 
 	plist_for_each_entry(heap, &dev->heaps, node) {
-		strncpy(hdata.name, heap->name, MAX_HEAP_NAME);
-		hdata.name[sizeof(hdata.name) - 1] = '\0';
+		stracpy(hdata.name, heap->name, MAX_HEAP_NAME);
 		hdata.type = heap->type;
 		hdata.heap_id = heap->id;
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] staging: android: ion: Replace strncpy() for stracpy()
@ 2019-09-08  4:34 ` Adam Zerella
  0 siblings, 0 replies; 8+ messages in thread
From: Adam Zerella @ 2019-09-08  4:34 UTC (permalink / raw)
  To: labbott, sumit.semwal
  Cc: devel, Adam Zerella, gregkh, linux-kernel, dri-devel, linaro-mm-sig

Using strncpy() does not always terminate the destination string.
stracpy() is a alternative function that does, by using this new
function we will no longer need to insert a null separator.

Signed-off-by: Adam Zerella <adam.zerella@gmail.com>
---
 drivers/staging/android/ion/ion.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index e6b1ca141b93..17901bd626be 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -433,8 +433,7 @@ static int ion_query_heaps(struct ion_heap_query *query)
 	max_cnt = query->cnt;
 
 	plist_for_each_entry(heap, &dev->heaps, node) {
-		strncpy(hdata.name, heap->name, MAX_HEAP_NAME);
-		hdata.name[sizeof(hdata.name) - 1] = '\0';
+		stracpy(hdata.name, heap->name, MAX_HEAP_NAME);
 		hdata.type = heap->type;
 		hdata.heap_id = heap->id;
 
-- 
2.21.0

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] staging: android: ion: Replace strncpy() for stracpy()
@ 2019-09-08  4:34 ` Adam Zerella
  0 siblings, 0 replies; 8+ messages in thread
From: Adam Zerella @ 2019-09-08  4:34 UTC (permalink / raw)
  To: labbott, sumit.semwal
  Cc: devel, Adam Zerella, gregkh, linux-kernel, dri-devel, linaro-mm-sig

Using strncpy() does not always terminate the destination string.
stracpy() is a alternative function that does, by using this new
function we will no longer need to insert a null separator.

Signed-off-by: Adam Zerella <adam.zerella@gmail.com>
---
 drivers/staging/android/ion/ion.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index e6b1ca141b93..17901bd626be 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -433,8 +433,7 @@ static int ion_query_heaps(struct ion_heap_query *query)
 	max_cnt = query->cnt;
 
 	plist_for_each_entry(heap, &dev->heaps, node) {
-		strncpy(hdata.name, heap->name, MAX_HEAP_NAME);
-		hdata.name[sizeof(hdata.name) - 1] = '\0';
+		stracpy(hdata.name, heap->name, MAX_HEAP_NAME);
 		hdata.type = heap->type;
 		hdata.heap_id = heap->id;
 
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] staging: android: ion: Replace strncpy() for stracpy()
  2019-09-08  4:34 ` Adam Zerella
  (?)
@ 2019-09-10 11:55   ` Dan Carpenter
  -1 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2019-09-10 11:55 UTC (permalink / raw)
  To: Adam Zerella
  Cc: labbott, sumit.semwal, devel, gregkh, linux-kernel, dri-devel,
	linaro-mm-sig

On Sun, Sep 08, 2019 at 02:34:50PM +1000, Adam Zerella wrote:
> Using strncpy() does not always terminate the destination string.
> stracpy() is a alternative function that does, by using this new
> function we will no longer need to insert a null separator.
> 
> Signed-off-by: Adam Zerella <adam.zerella@gmail.com>
> ---
>  drivers/staging/android/ion/ion.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
> index e6b1ca141b93..17901bd626be 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -433,8 +433,7 @@ static int ion_query_heaps(struct ion_heap_query *query)
>  	max_cnt = query->cnt;
>  
>  	plist_for_each_entry(heap, &dev->heaps, node) {
> -		strncpy(hdata.name, heap->name, MAX_HEAP_NAME);
> -		hdata.name[sizeof(hdata.name) - 1] = '\0';
> +		stracpy(hdata.name, heap->name, MAX_HEAP_NAME);

stracpy() only takes two arguments.  This doesn't compile.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] staging: android: ion: Replace strncpy() for stracpy()
@ 2019-09-10 11:55   ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2019-09-10 11:55 UTC (permalink / raw)
  To: Adam Zerella
  Cc: devel, gregkh, linux-kernel, dri-devel, linaro-mm-sig, sumit.semwal

On Sun, Sep 08, 2019 at 02:34:50PM +1000, Adam Zerella wrote:
> Using strncpy() does not always terminate the destination string.
> stracpy() is a alternative function that does, by using this new
> function we will no longer need to insert a null separator.
> 
> Signed-off-by: Adam Zerella <adam.zerella@gmail.com>
> ---
>  drivers/staging/android/ion/ion.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
> index e6b1ca141b93..17901bd626be 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -433,8 +433,7 @@ static int ion_query_heaps(struct ion_heap_query *query)
>  	max_cnt = query->cnt;
>  
>  	plist_for_each_entry(heap, &dev->heaps, node) {
> -		strncpy(hdata.name, heap->name, MAX_HEAP_NAME);
> -		hdata.name[sizeof(hdata.name) - 1] = '\0';
> +		stracpy(hdata.name, heap->name, MAX_HEAP_NAME);

stracpy() only takes two arguments.  This doesn't compile.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] staging: android: ion: Replace strncpy() for stracpy()
@ 2019-09-10 11:55   ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2019-09-10 11:55 UTC (permalink / raw)
  To: Adam Zerella; +Cc: devel, gregkh, linux-kernel, dri-devel, linaro-mm-sig

On Sun, Sep 08, 2019 at 02:34:50PM +1000, Adam Zerella wrote:
> Using strncpy() does not always terminate the destination string.
> stracpy() is a alternative function that does, by using this new
> function we will no longer need to insert a null separator.
> 
> Signed-off-by: Adam Zerella <adam.zerella@gmail.com>
> ---
>  drivers/staging/android/ion/ion.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
> index e6b1ca141b93..17901bd626be 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -433,8 +433,7 @@ static int ion_query_heaps(struct ion_heap_query *query)
>  	max_cnt = query->cnt;
>  
>  	plist_for_each_entry(heap, &dev->heaps, node) {
> -		strncpy(hdata.name, heap->name, MAX_HEAP_NAME);
> -		hdata.name[sizeof(hdata.name) - 1] = '\0';
> +		stracpy(hdata.name, heap->name, MAX_HEAP_NAME);

stracpy() only takes two arguments.  This doesn't compile.

regards,
dan carpenter

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] staging: android: ion: Replace strncpy() for stracpy()
  2019-09-10 11:55   ` Dan Carpenter
  (?)
  (?)
@ 2019-09-10 13:23   ` Adam Zerella
  2019-09-11 20:39     ` kbuild test robot
  -1 siblings, 1 reply; 8+ messages in thread
From: Adam Zerella @ 2019-09-10 13:23 UTC (permalink / raw)
  To: dan.carpenter; +Cc: devel, gregkh, Adam Zerella

Using strncpy() does not always terminate the destination string.
stracpy() is a alternative function that does, by using this new
function we will no longer need to insert a null separator.

Signed-off-by: Adam Zerella <adam.zerella@gmail.com>
---

v2: Remove unnecessary MAX_HEAP_NAME param from stracpy()
---
 drivers/staging/android/ion/ion.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index e6b1ca141b93..445bb951148f 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -433,8 +433,7 @@ static int ion_query_heaps(struct ion_heap_query *query)
 	max_cnt = query->cnt;
 
 	plist_for_each_entry(heap, &dev->heaps, node) {
-		strncpy(hdata.name, heap->name, MAX_HEAP_NAME);
-		hdata.name[sizeof(hdata.name) - 1] = '\0';
+		stracpy(hdata.name, heap->name);
 		hdata.type = heap->type;
 		hdata.heap_id = heap->id;
 
-- 
2.20.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] staging: android: ion: Replace strncpy() for stracpy()
  2019-09-10 13:23   ` [PATCH v2] " Adam Zerella
@ 2019-09-11 20:39     ` kbuild test robot
  0 siblings, 0 replies; 8+ messages in thread
From: kbuild test robot @ 2019-09-11 20:39 UTC (permalink / raw)
  To: Adam Zerella; +Cc: devel, gregkh, kbuild-all, dan.carpenter, Adam Zerella

[-- Attachment #1: Type: text/plain, Size: 2521 bytes --]

Hi Adam,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.3-rc8 next-20190904]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Adam-Zerella/staging-android-ion-Replace-strncpy-for-stracpy/20190912-024431
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=sparc64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/staging/android/ion/ion.c: In function 'ion_query_heaps':
>> drivers/staging/android/ion/ion.c:470:3: error: implicit declaration of function 'stracpy'; did you mean 'strscpy'? [-Werror=implicit-function-declaration]
      stracpy(hdata.name, heap->name);
      ^~~~~~~
      strscpy
   cc1: some warnings being treated as errors

vim +470 drivers/staging/android/ion/ion.c

   446	
   447	static int ion_query_heaps(struct ion_heap_query *query)
   448	{
   449		struct ion_device *dev = internal_dev;
   450		struct ion_heap_data __user *buffer = u64_to_user_ptr(query->heaps);
   451		int ret = -EINVAL, cnt = 0, max_cnt;
   452		struct ion_heap *heap;
   453		struct ion_heap_data hdata;
   454	
   455		memset(&hdata, 0, sizeof(hdata));
   456	
   457		down_read(&dev->lock);
   458		if (!buffer) {
   459			query->cnt = dev->heap_cnt;
   460			ret = 0;
   461			goto out;
   462		}
   463	
   464		if (query->cnt <= 0)
   465			goto out;
   466	
   467		max_cnt = query->cnt;
   468	
   469		plist_for_each_entry(heap, &dev->heaps, node) {
 > 470			stracpy(hdata.name, heap->name);
   471			hdata.type = heap->type;
   472			hdata.heap_id = heap->id;
   473	
   474			if (copy_to_user(&buffer[cnt], &hdata, sizeof(hdata))) {
   475				ret = -EFAULT;
   476				goto out;
   477			}
   478	
   479			cnt++;
   480			if (cnt >= max_cnt)
   481				break;
   482		}
   483	
   484		query->cnt = cnt;
   485		ret = 0;
   486	out:
   487		up_read(&dev->lock);
   488		return ret;
   489	}
   490	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 58680 bytes --]

[-- Attachment #3: Type: text/plain, Size: 169 bytes --]

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-09-11 20:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-08  4:34 [PATCH] staging: android: ion: Replace strncpy() for stracpy() Adam Zerella
2019-09-08  4:34 ` Adam Zerella
2019-09-08  4:34 ` Adam Zerella
2019-09-10 11:55 ` Dan Carpenter
2019-09-10 11:55   ` Dan Carpenter
2019-09-10 11:55   ` Dan Carpenter
2019-09-10 13:23   ` [PATCH v2] " Adam Zerella
2019-09-11 20:39     ` kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.