]> sourceware.org Git - lvm2.git/commitdiff
libdm: use literal for error message
authorZdenek Kabelac <zkabelac@redhat.com>
Sat, 4 May 2024 09:30:50 +0000 (11:30 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Tue, 7 May 2024 23:55:20 +0000 (01:55 +0200)
Use literals for printf messages.

device_mapper/libdm-report.c
libdm/libdm-report.c

index 2dca2513ef3e2acf4676a4beb1d1065b78b0ad63..86c95e109c0eb4c9b51c57d3cd6e88925af536c7 100644 (file)
@@ -2890,7 +2890,6 @@ typedef enum {
 
 static char *_get_date(char *str, struct tm *tm, time_range_t *range)
 {
-       static const char incorrect_date_format_msg[] = "Incorrect date format.";
        time_range_t tmp_range = RANGE_NONE;
        long n1, n2 = -1, n3 = -1;
        char *s = str, *end;
@@ -2936,19 +2935,15 @@ static char *_get_date(char *str, struct tm *tm, time_range_t *range)
                                n3 = n1 % 100;
                                n2 = (n1 / 100) % 100;
                                n1 = n1 / 10000;
-                       } else {
-                               log_error(incorrect_date_format_msg);
-                               return NULL;
-                       }
+                       } else
+                                goto_bad;
                } else {
                        if (len == 7) {
                                tmp_range = RANGE_MONTH;
                                /* YYYY-MM */
                                n3 = 1;
-                       } else {
-                               log_error(incorrect_date_format_msg);
-                               return NULL;
-                       }
+                       } else
+                               goto_bad;
                }
        }
 
@@ -2971,11 +2966,15 @@ static char *_get_date(char *str, struct tm *tm, time_range_t *range)
        *range = tmp_range;
 
        return (char *) _skip_space(end);
+
+bad:
+       log_error("Incorrect date format.");
+
+       return NULL;
 }
 
 static char *_get_time(char *str, struct tm *tm, time_range_t *range)
 {
-       static const char incorrect_time_format_msg[] = "Incorrect time format.";
        time_range_t tmp_range = RANGE_NONE;
        long n1, n2 = -1, n3 = -1;
        char *s = str, *end;
@@ -3023,19 +3022,15 @@ static char *_get_time(char *str, struct tm *tm, time_range_t *range)
                                n3 = n1 % 100;
                                n2 = (n1 / 100) % 100;
                                n1 = n1 / 10000;
-                       } else {
-                               log_error(incorrect_time_format_msg);
-                               return NULL;
-                       }
+                       } else
+                               goto_bad;
                } else {
                        if (len == 5) {
                                /* HH:MM */
                                tmp_range = RANGE_MINUTE;
                                n3 = 0;
-                       } else {
-                               log_error(incorrect_time_format_msg);
-                               return NULL;
-                       }
+                       } else
+                               goto_bad;
                }
        }
 
@@ -3066,6 +3061,11 @@ static char *_get_time(char *str, struct tm *tm, time_range_t *range)
        *range = tmp_range;
 
        return (char *) _skip_space(end);
+
+bad:
+       log_error("Incorrect time format.");
+
+       return NULL;
 }
 
 /* The offset is always an absolute offset against GMT! */
index 779a10d3f7e0b9cf94ddd05e15e4f508b098b100..d6a01060f73239b345a815017d13e15609a07662 100644 (file)
@@ -2888,7 +2888,6 @@ typedef enum {
 
 static char *_get_date(char *str, struct tm *tm, time_range_t *range)
 {
-       static const char incorrect_date_format_msg[] = "Incorrect date format.";
        time_range_t tmp_range = RANGE_NONE;
        long n1, n2 = -1, n3 = -1;
        char *s = str, *end;
@@ -2934,19 +2933,15 @@ static char *_get_date(char *str, struct tm *tm, time_range_t *range)
                                n3 = n1 % 100;
                                n2 = (n1 / 100) % 100;
                                n1 = n1 / 10000;
-                       } else {
-                               log_error(incorrect_date_format_msg);
-                               return NULL;
-                       }
+                       } else
+                                goto_bad;
                } else {
                        if (len == 7) {
                                tmp_range = RANGE_MONTH;
                                /* YYYY-MM */
                                n3 = 1;
-                       } else {
-                               log_error(incorrect_date_format_msg);
-                               return NULL;
-                       }
+                       } else
+                               goto_bad;
                }
        }
 
@@ -2969,11 +2964,15 @@ static char *_get_date(char *str, struct tm *tm, time_range_t *range)
        *range = tmp_range;
 
        return (char *) _skip_space(end);
+
+bad:
+       log_error("Incorrect date format.");
+
+       return NULL;
 }
 
 static char *_get_time(char *str, struct tm *tm, time_range_t *range)
 {
-       static const char incorrect_time_format_msg[] = "Incorrect time format.";
        time_range_t tmp_range = RANGE_NONE;
        long n1, n2 = -1, n3 = -1;
        char *s = str, *end;
@@ -3021,19 +3020,15 @@ static char *_get_time(char *str, struct tm *tm, time_range_t *range)
                                n3 = n1 % 100;
                                n2 = (n1 / 100) % 100;
                                n1 = n1 / 10000;
-                       } else {
-                               log_error(incorrect_time_format_msg);
-                               return NULL;
-                       }
+                       } else
+                               goto_bad;
                } else {
                        if (len == 5) {
                                /* HH:MM */
                                tmp_range = RANGE_MINUTE;
                                n3 = 0;
-                       } else {
-                               log_error(incorrect_time_format_msg);
-                               return NULL;
-                       }
+                       } else
+                               goto_bad;
                }
        }
 
@@ -3064,6 +3059,11 @@ static char *_get_time(char *str, struct tm *tm, time_range_t *range)
        *range = tmp_range;
 
        return (char *) _skip_space(end);
+
+bad:
+       log_error("Incorrect time format.");
+
+       return NULL;
 }
 
 /* The offset is always an absolute offset against GMT! */
This page took 0.061687 seconds and 5 git commands to generate.