Re: [PATCH v2] staging: android: ion: Replace strncpy() for stracpy()

2019-09-11 Thread kbuild test robot
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 

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(, 0, sizeof(hdata));
   456  
   457  down_read(>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, >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([cnt], , 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(>lock);
   488  return ret;
   489  }
   490  

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


.config.gz
Description: application/gzip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: android: ion: Replace strncpy() for stracpy()

2019-09-10 Thread 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 
---

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, >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
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel