[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/3] xen/console: Fix incorrect format tags for struct tm members
- To: Michal Orzel <michal.orzel@xxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Fri, 10 Jun 2022 11:44:29 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=omd2Vt6+O8ay33KHX7XNM3y+yoIHEFxI4gkDvfffja0=; b=GR5Bs64x+9phoQmYWJqvUzYfAQGDeXps4mEs6pjBgdCgTZcqy4vF0YQQuEAqjsvs0Mo7xsZzhRJyTQUA76eZrW4DidZ/l1h5m49Th+vvFE2n+Y6OZjcnd5lYaLz5UvpBqard5j1f5G22chefNea2sBsdCkiLgn1s+SkHsWUZcyDZlVdk93znDLpcYZFuCRVjPSygf9x4/UVvm9RxVHGT7Kw+65lH5we097bxXKhmbAkGdoicJomti0TDlYsxKbbGjML4v4ViJl5np9LYdAC2pFk4Ygp0RYfRhp2Dff2dSOlxjQT9hukP5JmjtIpq5VhO/erSxVbk1X4fcUizMnvplQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bA9JfcsYb64w4XZRrCT7V7Sqv9WiLP5i61iT+JpYWSnn2UvQSXvtXc45vRyVXWD6wu1kGoxWdYRqYF6h4DraHSpEXK3JA9bNpXsUDR+aWfp+anGSUEoD8Q6vjPg17I5AFkFX0gL58azNukOgy0cAMHTj8cwdDRi9rwMpzmm8vvqLqKNjqwtPh7Kgb5DJNKGfNQH9t4k41O09czPTJFF523jlT7SrNXOchzX+G+B0bD/W8o53/CuSADv+5ZsGWqQxz11snUzQ01A8Ptv+0UVsiT0qso3x3au84lFanLsfcBVrzxOP9AhABV1TtuX8CNVS/cczDNrCHITr+TznpLETQQ==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Fri, 10 Jun 2022 09:44:36 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 10.06.2022 10:33, Michal Orzel wrote:
> All the members of struct tm are defined as integers but the format tags
> used in console driver for snprintf wrongly expect unsigned values. Fix
> the tags to expect integers.
Perhaps do things the other way around - convert field types to unsigned
unless negative values can be stored there? This would match our general
aim of using unsigned types when only non-negative values can be held in
variables / parameters / fields.
Jan
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -844,7 +844,7 @@ static void printk_start_of_line(const char *prefix)
> /* nothing */;
> else if ( mode == TSM_DATE )
> {
> - snprintf(tstr, sizeof(tstr), "[%04u-%02u-%02u %02u:%02u:%02u] ",
> + snprintf(tstr, sizeof(tstr), "[%04d-%02d-%02d %02d:%02d:%02d] ",
> 1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday,
> tm.tm_hour, tm.tm_min, tm.tm_sec);
> break;
> @@ -852,7 +852,7 @@ static void printk_start_of_line(const char *prefix)
> else
> {
> snprintf(tstr, sizeof(tstr),
> - "[%04u-%02u-%02u %02u:%02u:%02u.%03"PRIu64"] ",
> + "[%04d-%02d-%02d %02d:%02d:%02d.%03"PRIu64"] ",
> 1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday,
> tm.tm_hour, tm.tm_min, tm.tm_sec, nsec / 1000000);
> break;
|