Skip to contentSkip to conversation

take sched_debug.c out of nasal demon territory

PATCH In review Al Viro 3 participants 4 messages Aug 6, 2007 – Aug 8, 2007

lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 1/1 take sched_debug.c out of nasal demon territory

C99 6.10.3[11]: preprocessing directive within the argument list
of macro invocation => undefined behaviour. Don't do that...

---

kernel/sched_debug.c +6 -6
index 1c61e53..8421b93 100644
@@ -36,24 +36,24 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p, u64 now)
 	else
 		SEQ_printf(m, " ");
 
-	SEQ_printf(m, "%15s %5d %15Ld %13Ld %13Ld %9Ld %5d "
-		      "%15Ld %15Ld %15Ld %15Ld %15Ld\n",
+	SEQ_printf(m, "%15s %5d %15Ld %13Ld %13Ld %9Ld %5d ",
 		p->comm, p->pid,
 		(long long)p->se.fair_key,
 		(long long)(p->se.fair_key - rq->cfs.fair_clock),
 		(long long)p->se.wait_runtime,
 		(long long)(p->nvcsw + p->nivcsw),
-		p->prio,
+		p->prio);
 #ifdef CONFIG_SCHEDSTATS
+	SEQ_printf(m, "%15Ld %15Ld %15Ld %15Ld %15Ld\n",
 		(long long)p->se.sum_exec_runtime,
 		(long long)p->se.sum_wait_runtime,
 		(long long)p->se.sum_sleep_runtime,
 		(long long)p->se.wait_runtime_overruns,
-		(long long)p->se.wait_runtime_underruns
+		(long long)p->se.wait_runtime_underruns);
 #else
-		0LL, 0LL, 0LL, 0LL, 0LL
+	SEQ_printf(m, "%15Ld %15Ld %15Ld %15Ld %15Ld\n",
+		0LL, 0LL, 0LL, 0LL, 0LL);
 #endif
-	);
 }
 
 static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu, u64 now)
#1 lore raw
Quoted 3 lines · Al Viro

C99 6.10.3[11]: preprocessing directive within the argument list
of macro invocation => undefined behaviour. Don't do that...

String concatenation ("a" "b") is not a preprocessing directive.

$ gcc -E test.c
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.c"
printf("a" "b");

(If it was, the "a" "b" would have already been joined.)

Jan

author
#2 lore raw
Quoted 7 lines · Jan Engelhardt
Quoted 3 lines · Al Viro

C99 6.10.3[11]: preprocessing directive within the argument list
of macro invocation => undefined behaviour. Don't do that...

String concatenation ("a" "b") is not a preprocessing directive.

It is not, but #ifdef definitely is.

#3 lore raw
In reply to Jan Engelhardt
Quoted 8 lines · Jan Engelhardt
Quoted 3 lines · Al Viro

C99 6.10.3[11]: preprocessing directive within the argument list
of macro invocation => undefined behaviour. Don't do that...

String concatenation ("a" "b") is not a preprocessing directive.

Quoted 9 lines
$ gcc -E test.c
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.c"
printf("a" "b");

(If it was, the "a" "b" would have already been joined.)

Yes. According to C99 5.1.1.2, string concatenation is done in Phase 6, that's after preprocessing.

Regards.

Signature · 4 lines
_   /|
\'o.O'
=(___)=
   U    ack!