lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <20cb25f6-add9-8944-3138-92f95c8b0d45@huawei.com> Date: Sat, 5 Jul 2025 08:39:51 +0800 From: zhanchengbin <zhanchengbin1@...wei.com> To: "Darrick J. Wong" <djwong@...nel.org> CC: Theodore Ts'o <tytso@....edu>, <linux-ext4@...r.kernel.org>, <qiangxiaojun@...wei.com>, <hejie3@...wei.com> Subject: Re: [PATCH v4] debugfs/logdump.c: Add parameter t to dump sequence commit timestamps On 2025/7/4 11:33, Darrick J. Wong worte: > On Fri, Jul 04, 2025 at 10:11:09AM +0800, zhanchengbin wrote: >> On 2025/7/3 23:39, Darrick J. Wong wrote: >>> On Thu, Jul 03, 2025 at 08:07:53PM +0800, zhanchengbin wrote: >>>> >>>> +static void dump_commit_time(FILE *out_file, char *buf) >>>> +{ >>>> + struct commit_header *header; >>>> + uint64_t commit_sec; >>>> + time_t timestamp; >>>> + char time_buffer[26]; >>>> + char *result; >>>> + >>>> + header = (struct commit_header *)buf; >>>> + commit_sec = be64_to_cpu(header->h_commit_sec); >>>> + >>>> + timestamp = commit_sec; >>>> + result = ctime_r(×tamp, time_buffer); >>>> + if (result) >>>> + fprintf(out_file, ", commit at: %s", time_buffer); >>> >>> Nit: missing newline in this fprintf... or you could delete the newline >>> below and change the callsite to: >>> >>> if (dump_time) >>> dump_commit_time(out_file, buf); >>> fprintf(out_file, "\n"); >>> >> >> In my test environment, the string generated by ctime_r comes with a >> newline character at the end. > > Oh, I guess that /is/ in the manpage: > > Broken-down time is stored in the structure tm, described in > tm(3type). > > The call ctime(t) is equivalent to asctime(localtime(t)). It > converts the calendar time t into a null-terminated string of > the form > > "Wed Jun 30 21:49:08 1993\n" > > and then POSIX has this to say about asctime(): > > The asctime() function shall convert the broken-down time in the > structure pointed to by timeptr into a string in the form: > > Sun Sep 16 01:03:52 1973\n\0 > > which is also in ISO C23: > > The asctime function converts the broken-down time in the > structure pointed to by timeptr into a string in the form: > > Sun Sep 16 01:03:52 1973\n\0 > > using the equivalent of the following algorithm. Get it. > > Sigh. > > Reviewed-by: "Darrick J. Wong" <djwong@...nel.org> Thanks, - bin. >>> >>> . >>> > > . >
Powered by blists - more mailing lists