* [PATCH] Some const for linux/time.h
@ 2006-07-27 20:40 Jan Engelhardt
2006-07-28 3:14 ` Josef Sipek
0 siblings, 1 reply; 3+ messages in thread
From: Jan Engelhardt @ 2006-07-27 20:40 UTC (permalink / raw)
To: akpm; +Cc: Linux Kernel Mailing List
Hello,
time compare functions do not modify their arguments, so they can
be marked as const (like some of the functions in time.h are already).
Signed-off-by: Jan Engelhardt <jengelh@gmx.de>
diff --fast -Ndpru linux-2.6.17.7~/include/linux/time.h linux-2.6.17.7+/include/linux/time.h
--- linux-2.6.17.7~/include/linux/time.h 2006-06-06 02:57:02.000000000 +0200
+++ linux-2.6.17.7+/include/linux/time.h 2006-07-27 22:35:53.308571000 +0200
@@ -33,7 +33,8 @@ struct timezone {
#define NSEC_PER_SEC 1000000000L
#define NSEC_PER_USEC 1000L
-static inline int timespec_equal(struct timespec *a, struct timespec *b)
+static inline int timespec_equal(const struct timespec *a,
+ const struct timespec *b)
{
return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);
}
@@ -43,7 +44,8 @@ static inline int timespec_equal(struct
* lhs == rhs: return 0
* lhs > rhs: return >0
*/
-static inline int timespec_compare(struct timespec *lhs, struct timespec *rhs)
+static inline int timespec_compare(const struct timespec *lhs,
+ struct timespec *rhs)
{
if (lhs->tv_sec < rhs->tv_sec)
return -1;
@@ -52,7 +54,8 @@ static inline int timespec_compare(struc
return lhs->tv_nsec - rhs->tv_nsec;
}
-static inline int timeval_compare(struct timeval *lhs, struct timeval *rhs)
+static inline int timeval_compare(const struct timeval *lhs,
+ const struct timeval *rhs)
{
if (lhs->tv_sec < rhs->tv_sec)
return -1;
#<<eof>>
Jan Engelhardt
--
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Some const for linux/time.h
2006-07-27 20:40 [PATCH] Some const for linux/time.h Jan Engelhardt
@ 2006-07-28 3:14 ` Josef Sipek
2006-07-28 13:46 ` Jan Engelhardt
0 siblings, 1 reply; 3+ messages in thread
From: Josef Sipek @ 2006-07-28 3:14 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: akpm, Linux Kernel Mailing List
On Thu, Jul 27, 2006 at 10:40:47PM +0200, Jan Engelhardt wrote:
> Hello,
>
>
> time compare functions do not modify their arguments, so they can
> be marked as const (like some of the functions in time.h are already).
>
> Signed-off-by: Jan Engelhardt <jengelh@gmx.de>
>
> diff --fast -Ndpru linux-2.6.17.7~/include/linux/time.h linux-2.6.17.7+/include/linux/time.h
> --- linux-2.6.17.7~/include/linux/time.h 2006-06-06 02:57:02.000000000 +0200
> +++ linux-2.6.17.7+/include/linux/time.h 2006-07-27 22:35:53.308571000 +0200
> @@ -33,7 +33,8 @@ struct timezone {
> #define NSEC_PER_SEC 1000000000L
> #define NSEC_PER_USEC 1000L
>
> -static inline int timespec_equal(struct timespec *a, struct timespec *b)
> +static inline int timespec_equal(const struct timespec *a,
> + const struct timespec *b)
As per CodingStyle, the second line should be "placed substantially to the
right."
Josef Sipek.
--
Humans were created by water to transport it upward.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Some const for linux/time.h
2006-07-28 3:14 ` Josef Sipek
@ 2006-07-28 13:46 ` Jan Engelhardt
0 siblings, 0 replies; 3+ messages in thread
From: Jan Engelhardt @ 2006-07-28 13:46 UTC (permalink / raw)
To: Josef Sipek; +Cc: akpm, Linux Kernel Mailing List
>>
>> -static inline int timespec_equal(struct timespec *a, struct timespec *b)
>> +static inline int timespec_equal(const struct timespec *a,
>> + const struct timespec *b)
>
>As per CodingStyle, the second line should be "placed substantially to the
>right."
Is one space to few "substance"? How about ... MORE substance
diff --fast -Ndpru linux-2.6.17.7~/include/linux/time.h linux-2.6.17.7+/include/linux/time.h
--- linux-2.6.17.7~/include/linux/time.h 2006-06-06 02:57:02.000000000 +0200
+++ linux-2.6.17.7+/include/linux/time.h 2006-07-27 22:35:53.308571000 +0200
@@ -33,7 +33,8 @@ struct timezone {
#define NSEC_PER_SEC 1000000000L
#define NSEC_PER_USEC 1000L
-static inline int timespec_equal(struct timespec *a, struct timespec *b)
+static inline int timespec_equal(const struct timespec *a,
+ const struct timespec *b)
{
return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);
}
@@ -43,7 +44,8 @@ static inline int timespec_equal(struct
* lhs == rhs: return 0
* lhs > rhs: return >0
*/
-static inline int timespec_compare(struct timespec *lhs, struct timespec *rhs)
+static inline int timespec_compare(const struct timespec *lhs,
+ const struct timespec *rhs)
{
if (lhs->tv_sec < rhs->tv_sec)
return -1;
@@ -52,7 +54,8 @@ static inline int timespec_compare(struc
return lhs->tv_nsec - rhs->tv_nsec;
}
-static inline int timeval_compare(struct timeval *lhs, struct timeval *rhs)
+static inline int timeval_compare(const struct timeval *lhs,
+ const struct timeval *rhs)
{
if (lhs->tv_sec < rhs->tv_sec)
return -1;
#
SCNR. Don't take this one seriously. But the previous one.
Jan Engelhardt
--
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-07-28 13:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-27 20:40 [PATCH] Some const for linux/time.h Jan Engelhardt
2006-07-28 3:14 ` Josef Sipek
2006-07-28 13:46 ` Jan Engelhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®