All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 01/25] linux/time64.h:Introduce the 'struct itimerspec64' for 64bit
@ 2015-06-01 11:48 Baolin Wang
  2015-06-02 19:19 ` Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: Baolin Wang @ 2015-06-01 11:48 UTC (permalink / raw)
  To: tglx; +Cc: arnd, john.stultz, linux-kernel, baolin.wang, y2038

This patch introduces the 'struct itimerspec64' for 64bit to replace itimerspec,
and also introduces the conversion methods: itimerspec64_to_itimerspec() and
itimerspec_to_itimerspec64(), that makes itimerspec ready for 2038 year.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 include/linux/time64.h |   35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/include/linux/time64.h b/include/linux/time64.h
index a383147..61dc4cb 100644
--- a/include/linux/time64.h
+++ b/include/linux/time64.h
@@ -11,11 +11,18 @@ typedef __s64 time64_t;
  */
 #if __BITS_PER_LONG == 64
 # define timespec64 timespec
+#define itimerspec64 itimerspec
 #else
 struct timespec64 {
 	time64_t	tv_sec;			/* seconds */
 	long		tv_nsec;		/* nanoseconds */
 };
+
+struct itimerspec64 {
+	struct timespec64 it_interval;  /* timer period */
+	struct timespec64 it_value;     /* timer expiration */
+};
+
 #endif
 
 /* Parameters used to convert the timespec values: */
@@ -43,6 +50,16 @@ static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
 	return ts;
 }
 
+static inline struct itimerspec itimerspec64_to_itimerspec(struct itimerspec64 *its64)
+{
+	return *its64;
+}
+
+static inline struct itimerspec64 itimerspec_to_itimerspec64(struct itimerspec *its)
+{
+	return *its;
+}
+
 # define timespec64_equal		timespec_equal
 # define timespec64_compare		timespec_compare
 # define set_normalized_timespec64	set_normalized_timespec
@@ -75,6 +92,24 @@ static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
 	return ret;
 }
 
+static inline struct itimerspec itimerspec64_to_itimerspec(struct itimerspec64 *its64)
+{
+	struct itimerspec ret;
+
+	ret.it_interval = timespec64_to_timespec(its64->it_interval);
+	ret.it_value = timespec64_to_timespec(its64->it_value);
+	return ret;
+}
+
+static inline struct itimerspec64 itimerspec_to_itimerspec64(struct itimerspec *its)
+{
+	struct itimerspec64 ret;
+
+	ret.it_interval = timespec_to_timespec64(its->it_interval);
+	ret.it_value = timespec_to_timespec64(its->it_value);
+	return ret;
+}
+
 static inline int timespec64_equal(const struct timespec64 *a,
 				   const struct timespec64 *b)
 {
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v4 01/25] linux/time64.h:Introduce the 'struct itimerspec64' for 64bit
  2015-06-01 11:48 [PATCH v4 01/25] linux/time64.h:Introduce the 'struct itimerspec64' for 64bit Baolin Wang
@ 2015-06-02 19:19 ` Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2015-06-02 19:19 UTC (permalink / raw)
  To: Baolin Wang; +Cc: arnd, john.stultz, linux-kernel, y2038

On Mon, 1 Jun 2015, Baolin Wang wrote:

> Subject: linux/time64.h:Introduce the 'struct itimerspec64' for 64bit

This subject line is wrong in several aspects:

 - linux/time64.h is a file name and does not describe the subsystem
   you are changing. 'time:' is the proper choice here

 - Missing space between colon and first word of the sentence

 - What means struct itimerspec64 for 64bit? Is this a 64bit only
   variant or what?


"Subject: time: Introduce struct itimerspec64"

is the proper subject line as it names the subsystem (time) and tells
clearly what the patch does.

> This patch introduces the 'struct itimerspec64' for 64bit to replace itimerspec,

Again: 'for 64bit' is really wrong here.

> and also introduces the conversion methods: itimerspec64_to_itimerspec() and
> itimerspec_to_itimerspec64(), that makes itimerspec ready for 2038 year.

You explain in great length WHAT the patch is doing, which is
pointless because one can see that from the patch itself. You should
explain WHY you are doing this first.

"itimerspec is not year 2038 safe on 32bit systems due to the
 limitation of the struct timespec members. Introduce itimerspec64
 which uses struct timespec64 instead and provide conversion
 functions"

Hmm?


> +struct itimerspec64 {
> +	struct timespec64 it_interval;  /* timer period */
> +	struct timespec64 it_value;     /* timer expiration */

I really hate tail comments. If you want to document your structure
use proper KernelDoc for it.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-02 19:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-01 11:48 [PATCH v4 01/25] linux/time64.h:Introduce the 'struct itimerspec64' for 64bit Baolin Wang
2015-06-02 19:19 ` Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.