소스 검색

utarray.h: preserve constness in utarray_str_cpy

Make local variable const * to preserve the constness of the passed
argument src. This fixes compiler warnings from -Wcast-qual.
Olaf Bergmann 5 년 전
부모
커밋
ba2fbfdcd8
1개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 2
      src/utarray.h

+ 3 - 2
src/utarray.h

@@ -232,8 +232,9 @@ typedef struct {
 
 /* last we pre-define a few icd for common utarrays of ints and strings */
 static void utarray_str_cpy(void *dst, const void *src) {
-  char **_src = (char**)src, **_dst = (char**)dst;
-  *_dst = (*_src == NULL) ? NULL : strdup(*_src);
+  char *const *srcc = (char *const *)src;
+  char **dstc = (char**)dst;
+  *dstc = (*srcc == NULL) ? NULL : strdup(*srcc);
 }
 static void utarray_str_dtor(void *elt) {
   char **eltc = (char**)elt;