nathanchance wrote:
For what it's worth, this causes `-Wstring-concatenation` to pop up a few times
in the Linux kernel. Two of the instances are simple enough to resolve under
the kernel's "Do not split user visible strings regardless of length" rule.
```
drivers/scsi/lpfc/lpfc_attr.c:76:3: warning: suspicious concatenation of string
literals in an array initialization; did you mean to separate the elements with
a comma? [-Wstring-concatenation]
75 | "link negotiated speed does not match existing"
|
| ,
76 | " trunk - link was \"high\" speed",
| ^
drivers/scsi/lpfc/lpfc_attr.c:75:2: note: place parentheses around the string
literal to silence warning
75 | "link negotiated speed does not match existing"
| ^
```
```c
const char *const trunk_errmsg[] = { /* map errcode */
"", /* There is no such error code at index 0*/
"link negotiated speed does not match existing"
" trunk - link was \"low\" speed",
"link negotiated speed does not match"
" existing trunk - link was \"middle\" speed",
"link negotiated speed does not match existing"
" trunk - link was \"high\" speed",
"Attached to non-trunking port - F_Port",
"Attached to non-trunking port - N_Port",
"FLOGI response timeout",
"non-FLOGI frame received",
"Invalid FLOGI response",
"Trunking initialization protocol",
"Trunk peer device mismatch",
};
```
```diff
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 33582d48ec09..433cddcae4b6 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -68,12 +68,9 @@
const char *const trunk_errmsg[] = { /* map errcode */
"", /* There is no such error code at index 0*/
- "link negotiated speed does not match existing"
- " trunk - link was \"low\" speed",
- "link negotiated speed does not match"
- " existing trunk - link was \"middle\" speed",
- "link negotiated speed does not match existing"
- " trunk - link was \"high\" speed",
+ "link negotiated speed does not match existing trunk - link was \"low\"
speed",
+ "link negotiated speed does not match existing trunk - link was
\"middle\" speed",
+ "link negotiated speed does not match existing trunk - link was
\"high\" speed",
"Attached to non-trunking port - F_Port",
"Attached to non-trunking port - N_Port",
"FLOGI response timeout",
```
```
drivers/edac/i7300_edac.c:197:9: warning: suspicious concatenation of string
literals in an array initialization; did you mean to separate the elements with
a comma? [-Wstring-concatenation]
196 | [0] = "Memory Write error on non-redundant retry or "
|
| ,
197 | "FBD configuration Write error on retry",
| ^
drivers/edac/i7300_edac.c:196:9: note: place parentheses around the string
literal to silence warning
196 | [0] = "Memory Write error on non-redundant retry or "
| ^
```
```c
static const char *ferr_fat_fbd_name[] = {
[22] = "Non-Redundant Fast Reset Timeout",
[2] = ">Tmid Thermal event with intelligent throttling disabled",
[1] = "Memory or FBD configuration CRC read error",
[0] = "Memory Write error on non-redundant retry or "
"FBD configuration Write error on retry",
};
```
```diff
diff --git a/drivers/edac/i7300_edac.c b/drivers/edac/i7300_edac.c
index 69068f8d0cad..939b855e8fbf 100644
--- a/drivers/edac/i7300_edac.c
+++ b/drivers/edac/i7300_edac.c
@@ -193,8 +193,7 @@ static const char *ferr_fat_fbd_name[] = {
[22] = "Non-Redundant Fast Reset Timeout",
[2] = ">Tmid Thermal event with intelligent throttling disabled",
[1] = "Memory or FBD configuration CRC read error",
- [0] = "Memory Write error on non-redundant retry or "
- "FBD configuration Write error on retry",
+ [0] = "Memory Write error on non-redundant retry or FBD configuration
Write error on retry",
};
#define GET_FBD_FAT_IDX(fbderr) (((fbderr) >> 28) & 3)
#define FERR_FAT_FBD_ERR_MASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 22))
```
However, this third one is a little interesting because the warning happens on
the last instance of a sequence of multi-line concatenations:
```
drivers/net/dsa/sja1105/sja1105_static_config.c:991:3: warning: suspicious
concatenation of string literals in an array initialization; did you mean to
separate the elements with a comma? [-Wstring-concatenation]
990 | "vl-lookup-table present, but one of vl-policing-table,
"
|
|
,
991 | "vl-forwarding-table or vl-forwarding-parameters-table
is empty",
| ^
drivers/net/dsa/sja1105/sja1105_static_config.c:990:3: note: place parentheses
around the string literal to silence warning
990 | "vl-lookup-table present, but one of vl-policing-table,
"
| ^
```
```c
const char *sja1105_static_config_error_msg[] = {
[SJA1105_CONFIG_OK] = "",
[SJA1105_TTETHERNET_NOT_SUPPORTED] =
"schedule-table present, but TTEthernet is "
"only supported on T and Q/S",
[SJA1105_INCORRECT_TTETHERNET_CONFIGURATION] =
"schedule-table present, but one of "
"schedule-entry-points-table, schedule-parameters-table or "
"schedule-entry-points-parameters table is empty",
[SJA1105_INCORRECT_VIRTUAL_LINK_CONFIGURATION] =
"vl-lookup-table present, but one of vl-policing-table, "
"vl-forwarding-table or vl-forwarding-parameters-table is empty",
[SJA1105_MISSING_L2_POLICING_TABLE] =
"l2-policing-table needs to have at least one entry",
[SJA1105_MISSING_L2_FORWARDING_TABLE] =
"l2-forwarding-table is either missing or incomplete",
[SJA1105_MISSING_L2_FORWARDING_PARAMS_TABLE] =
"l2-forwarding-parameters-table is missing",
[SJA1105_MISSING_GENERAL_PARAMS_TABLE] =
"general-parameters-table is missing",
[SJA1105_MISSING_VLAN_TABLE] =
"vlan-lookup-table needs to have at least the default untagged VLAN",
[SJA1105_MISSING_XMII_TABLE] =
"xmii-table is missing",
[SJA1105_MISSING_MAC_TABLE] =
"mac-configuration-table needs to contain an entry for each port",
[SJA1105_OVERCOMMITTED_FRAME_MEMORY] =
"Not allowed to overcommit frame memory. L2 memory partitions "
"and VL memory partitions share the same space. The sum of all "
"16 memory partitions is not allowed to be larger than 929 "
"128-byte blocks (or 910 with retagging). Please adjust "
"l2-forwarding-parameters-table.part_spc and/or "
"vl-forwarding-parameters-table.partspc.",
};
```
I will probably suggest fixing it like so just to be consistent but I am sure
someone will ask why it only flags the third instance and none of the others (I
realize because of the heuristic but still).
```diff
diff --git a/drivers/net/dsa/sja1105/sja1105_static_config.c
b/drivers/net/dsa/sja1105/sja1105_static_config.c
index ffece8a400a6..45564b62ce41 100644
--- a/drivers/net/dsa/sja1105/sja1105_static_config.c
+++ b/drivers/net/dsa/sja1105/sja1105_static_config.c
@@ -980,15 +980,15 @@ static u64 blk_id_map[BLK_IDX_MAX] = {
const char *sja1105_static_config_error_msg[] = {
[SJA1105_CONFIG_OK] = "",
[SJA1105_TTETHERNET_NOT_SUPPORTED] =
- "schedule-table present, but TTEthernet is "
- "only supported on T and Q/S",
+ ("schedule-table present, but TTEthernet is "
+ "only supported on T and Q/S"),
[SJA1105_INCORRECT_TTETHERNET_CONFIGURATION] =
- "schedule-table present, but one of "
+ ("schedule-table present, but one of "
"schedule-entry-points-table, schedule-parameters-table or "
- "schedule-entry-points-parameters table is empty",
+ "schedule-entry-points-parameters table is empty"),
[SJA1105_INCORRECT_VIRTUAL_LINK_CONFIGURATION] =
- "vl-lookup-table present, but one of vl-policing-table, "
- "vl-forwarding-table or vl-forwarding-parameters-table is
empty",
+ ("vl-lookup-table present, but one of vl-policing-table, "
+ "vl-forwarding-table or vl-forwarding-parameters-table is
empty"),
[SJA1105_MISSING_L2_POLICING_TABLE] =
"l2-policing-table needs to have at least one entry",
[SJA1105_MISSING_L2_FORWARDING_TABLE] =
@@ -1004,12 +1004,12 @@ const char *sja1105_static_config_error_msg[] = {
[SJA1105_MISSING_MAC_TABLE] =
"mac-configuration-table needs to contain an entry for each
port",
[SJA1105_OVERCOMMITTED_FRAME_MEMORY] =
- "Not allowed to overcommit frame memory. L2 memory partitions "
+ ("Not allowed to overcommit frame memory. L2 memory partitions "
"and VL memory partitions share the same space. The sum of all "
"16 memory partitions is not allowed to be larger than 929 "
"128-byte blocks (or 910 with retagging). Please adjust "
"l2-forwarding-parameters-table.part_spc and/or "
- "vl-forwarding-parameters-table.partspc.",
+ "vl-forwarding-parameters-table.partspc."),
};
static sja1105_config_valid_t
```
Maybe this warning could take into account using designators probably means the
concatenation is intentional? Not sure if that is possible.
https://github.com/llvm/llvm-project/pull/154018
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits