Hello,

Balaji, Pavan via hwloc-users, le lun. 01 juin 2020 03:39:02 +0000, a ecrit:
> We are seeing some warnings with the Intel compiler with hwloc (listed 
> below).  The warnings seem to be somewhat silly because there already is a 
> cast to "char *" from the string literal,

Well, I'd agree with icc that casting a string literal to (char*) is in
general a bad idea :)

> but it seems to expect a cast to "const char *" before casting to "char *".  
> We are maintaining the below patch to workaround it.  Can you either 
> integrate this or a better fix for the warning?
> 
> https://github.com/pmodels/hwloc/commit/fb27dc6e21bac14754d1b50b57f752e37d475704

I fixed them except:

>   CC       topology-hardwired.lo
> traversal.c(598): warning #3179: deprecated conversion of string literal to 
> char* (should be const char*)
>         const char *quote = strchr(info->value, ' ') ? "\"" : "";
>                                                             ^

Which is more silly (these are already const char* in essence) and just
seems to me like icc's limited analysis.  Our version of icc doesn't get
these, could you check whether the attached patch avoids the warning?
(we should really not need a cast to const char*)

Samuel
diff --git a/hwloc/traversal.c b/hwloc/traversal.c
index 4062a19d..14549422 100644
--- a/hwloc/traversal.c
+++ b/hwloc/traversal.c
@@ -654,7 +654,11 @@ hwloc_obj_attr_snprintf(char * __hwloc_restrict string, 
size_t size, hwloc_obj_t
     unsigned i;
     for(i=0; i<obj->infos_count; i++) {
       struct hwloc_info_s *info = &obj->infos[i];
-      const char *quote = strchr(info->value, ' ') ? "\"" : "";
+      const char *quote;
+      if (strchr(info->value, ' '))
+        quote = "\"";
+      else
+        quote = "";
       res = hwloc_snprintf(tmp, tmplen, "%s%s=%s%s%s",
                             prefix,
                             info->name,
_______________________________________________
hwloc-users mailing list
hwloc-users@lists.open-mpi.org
https://lists.open-mpi.org/mailman/listinfo/hwloc-users

Reply via email to