From cca4f7b2d999a916e664b1331f20c754d454eb95 Mon Sep 17 00:00:00 2001 From: obrien Date: Mon, 10 Dec 2001 05:40:12 +0000 Subject: [PATCH] Repeat after me -- "Use of ANSI string concatenation can be bad." In this case, C99's __func__ is properly defined as: static const char __func__[] = "function-name"; and GCC 3.1 will not allow it to be used in bogus string concatenation. --- sys/kern/kern_exec.c | 2 +- sys/kern/kern_intr.c | 32 ++++++++++++++++---------------- sys/kern/kern_sema.c | 16 ++++++++-------- sys/kern/subr_witness.c | 26 +++++++++++++------------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 6095b62ba024..41ff7d89c2b5 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -128,7 +128,7 @@ execve(td, uap) mtx_lock(&Giant); PROC_LOCK(p); KASSERT((p->p_flag & P_INEXEC) == 0, - (__FUNCTION__ "(): process already has P_INEXEC flag")); + ("%s(): process already has P_INEXEC flag", __func__)); p->p_flag |= P_INEXEC; PROC_UNLOCK(p); diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index 15ae4ffe17da..e873c6eca819 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -160,7 +160,7 @@ ithread_update(struct ithd *ithd) else ithd->it_flags &= ~IT_ENTROPY; - CTR1(KTR_INTR, __func__ ": updated %s\n", p->p_comm); + CTR2(KTR_INTR, "%s: updated %s\n", __func__, p->p_comm); } int @@ -207,7 +207,7 @@ ithread_create(struct ithd **ithread, int vector, int flags, *ithread = ithd; mtx_unlock(&ithd->it_lock); - CTR1(KTR_INTR, __func__ ": created %s", ithd->it_name); + CTR2(KTR_INTR, "%s: created %s", __func__, ithd->it_name); return (0); } @@ -235,7 +235,7 @@ ithread_destroy(struct ithd *ithread) } mtx_unlock_spin(&sched_lock); mtx_unlock(&ithread->it_lock); - CTR1(KTR_INTR, __func__ ": killing %s", ithread->it_name); + CTR2(KTR_INTR, "%s: killing %s", __func__, ithread->it_name); return (0); } @@ -285,7 +285,7 @@ ithread_add_handler(struct ithd* ithread, const char *name, if (cookiep != NULL) *cookiep = ih; - CTR2(KTR_INTR, __func__ ": added %s to %s", ih->ih_name, + CTR3(KTR_INTR, "%s: added %s to %s", __func__, ih->ih_name, ithread->it_name); return (0); @@ -310,7 +310,7 @@ ithread_remove_handler(void *cookie) KASSERT(ithread != NULL, ("interrupt handler \"%s\" has a NULL interrupt thread", handler->ih_name)); - CTR2(KTR_INTR, __func__ ": removing %s from %s", handler->ih_name, + CTR3(KTR_INTR, "%s: removing %s from %s", __func__, handler->ih_name, ithread->it_name); mtx_lock(&ithread->it_lock); #ifdef INVARIANTS @@ -374,7 +374,7 @@ ithread_schedule(struct ithd *ithread, int do_switch) td = ithread->it_td; p = td->td_proc; KASSERT(p != NULL, ("ithread %s has no process", ithread->it_name)); - CTR3(KTR_INTR, __func__ ": pid %d: (%s) need = %d", p->p_pid, p->p_comm, + CTR4(KTR_INTR, "%s: pid %d: (%s) need = %d", __func__, p->p_pid, p->p_comm, ithread->it_need); /* @@ -388,7 +388,7 @@ ithread_schedule(struct ithd *ithread, int do_switch) ithread->it_need = 1; mtx_lock_spin(&sched_lock); if (p->p_stat == SWAIT) { - CTR1(KTR_INTR, __func__ ": setrunqueue %d", p->p_pid); + CTR2(KTR_INTR, "%s: setrunqueue %d", __func__, p->p_pid); p->p_stat = SRUN; setrunqueue(td); /* XXXKSE */ if (do_switch && curthread->td_proc->p_stat == SRUN) { @@ -399,8 +399,8 @@ ithread_schedule(struct ithd *ithread, int do_switch) } else curthread->td_kse->ke_flags |= KEF_NEEDRESCHED; } else { - CTR3(KTR_INTR, __func__ ": pid %d: it_need %d, state %d", - p->p_pid, ithread->it_need, p->p_stat); + CTR4(KTR_INTR, "%s: pid %d: it_need %d, state %d", + __func__, p->p_pid, ithread->it_need, p->p_stat); } mtx_unlock_spin(&sched_lock); @@ -478,7 +478,7 @@ ithread_loop(void *arg) p = td->td_proc; ithd = (struct ithd *)arg; /* point to myself */ KASSERT(ithd->it_td == td && td->td_ithd == ithd, - (__func__ ": ithread and proc linkage out of sync")); + ("%s: ithread and proc linkage out of sync", __func__)); /* * As long as we have interrupts outstanding, go through the @@ -489,7 +489,7 @@ ithread_loop(void *arg) * If we are an orphaned thread, then just die. */ if (ithd->it_flags & IT_DEAD) { - CTR2(KTR_INTR, __func__ ": pid %d: (%s) exiting", + CTR3(KTR_INTR, "%s: pid %d: (%s) exiting", __func__, p->p_pid, p->p_comm); td->td_ithd = NULL; mtx_destroy(&ithd->it_lock); @@ -498,7 +498,7 @@ ithread_loop(void *arg) kthread_exit(0); } - CTR3(KTR_INTR, __func__ ": pid %d: (%s) need=%d", + CTR4(KTR_INTR, "%s: pid %d: (%s) need=%d", __func__, p->p_pid, p->p_comm, ithd->it_need); while (ithd->it_need) { /* @@ -513,8 +513,8 @@ restart: if (ithd->it_flags & IT_SOFT && !ih->ih_need) continue; atomic_store_rel_int(&ih->ih_need, 0); - CTR5(KTR_INTR, - __func__ ": pid %d ih=%p: %p(%p) flg=%x", + CTR6(KTR_INTR, + "%s: pid %d ih=%p: %p(%p) flg=%x", __func__, p->p_pid, (void *)ih, (void *)ih->ih_handler, ih->ih_argument, ih->ih_flags); @@ -550,9 +550,9 @@ restart: ithd->it_enable(ithd->it_vector); p->p_stat = SWAIT; /* we're idle */ p->p_stats->p_ru.ru_nvcsw++; - CTR1(KTR_INTR, __func__ ": pid %d: done", p->p_pid); + CTR2(KTR_INTR, "%s: pid %d: done", __func__, p->p_pid); mi_switch(); - CTR1(KTR_INTR, __func__ ": pid %d: resumed", p->p_pid); + CTR2(KTR_INTR, "%s: pid %d: resumed", __func__, p->p_pid); } mtx_unlock_spin(&sched_lock); } diff --git a/sys/kern/kern_sema.c b/sys/kern/kern_sema.c index 013cddc16d77..cb47ba9d5067 100644 --- a/sys/kern/kern_sema.c +++ b/sys/kern/kern_sema.c @@ -55,14 +55,14 @@ sema_init(struct sema *sema, int value, const char *description) cv_init(&sema->sema_cv, description); sema->sema_value = value; - CTR3(KTR_LOCK, __func__ "(%p, %d, \"%s\")", sema, value, description); + CTR4(KTR_LOCK, "%s(%p, %d, \"%s\")", __func__, sema, value, description); } void sema_destroy(struct sema *sema) { - CTR2(KTR_LOCK, __func__ "(%p) \"%s\"", sema, + CTR3(KTR_LOCK, "%s(%p) \"%s\"", __func__, sema, cv_wmesg(&sema->sema_cv)); KASSERT((sema->sema_waiters == 0), ("%s(): waiters\n", __func__)); @@ -80,7 +80,7 @@ _sema_post(struct sema *sema, const char *file, int line) if (sema->sema_waiters && sema->sema_value > 0) cv_signal(&sema->sema_cv); - CTR5(KTR_LOCK, __func__ "(%p) \"%s\" v = %d at %s:%d", sema, + CTR6(KTR_LOCK, "%s(%p) \"%s\" v = %d at %s:%d", __func__, sema, cv_wmesg(&sema->sema_cv), sema->sema_value, file, line); mtx_unlock(&sema->sema_mtx); @@ -98,7 +98,7 @@ _sema_wait(struct sema *sema, const char *file, int line) } sema->sema_value--; - CTR5(KTR_LOCK, __func__ "(%p) \"%s\" v = %d at %s:%d", sema, + CTR6(KTR_LOCK, "%s(%p) \"%s\" v = %d at %s:%d", __func__, sema, cv_wmesg(&sema->sema_cv), sema->sema_value, file, line); mtx_unlock(&sema->sema_mtx); @@ -127,12 +127,12 @@ _sema_timedwait(struct sema *sema, int timo, const char *file, int line) sema->sema_value--; ret = 1; - CTR5(KTR_LOCK, __func__ "(%p) \"%s\" v = %d at %s:%d", sema, + CTR6(KTR_LOCK, "%s(%p) \"%s\" v = %d at %s:%d", __func__, sema, cv_wmesg(&sema->sema_cv), sema->sema_value, file, line); } else { ret = 0; - CTR4(KTR_LOCK, __func__ "(%p) \"%s\" fail at %s:%d", sema, + CTR5(KTR_LOCK, "%s(%p) \"%s\" fail at %s:%d", __func__, sema, cv_wmesg(&sema->sema_cv), file, line); } @@ -152,12 +152,12 @@ _sema_trywait(struct sema *sema, const char *file, int line) sema->sema_value--; ret = 1; - CTR5(KTR_LOCK, __func__ "(%p) \"%s\" v = %d at %s:%d", sema, + CTR6(KTR_LOCK, "%s(%p) \"%s\" v = %d at %s:%d", __func__, sema, cv_wmesg(&sema->sema_cv), sema->sema_value, file, line); } else { ret = 0; - CTR4(KTR_LOCK, __func__ "(%p) \"%s\" fail at %s:%d", sema, + CTR5(KTR_LOCK, "%s(%p) \"%s\" fail at %s:%d", __func__, sema, cv_wmesg(&sema->sema_cv), file, line); } diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index b91f7a2a8bd6..454fd55c76eb 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -286,7 +286,7 @@ witness_initialize(void *dummy __unused) mtx_unlock(&Giant); mtx_assert(&Giant, MA_NOTOWNED); - CTR0(KTR_WITNESS, __func__ ": initializing witness"); + CTR1(KTR_WITNESS, "%s: initializing witness", __func__); STAILQ_INSERT_HEAD(&all_locks, &all_mtx.mtx_object, lo_list); mtx_init(&w_mtx, "witness lock", MTX_SPIN | MTX_QUIET | MTX_NOWITNESS); for (i = 0; i < WITNESS_COUNT; i++) @@ -384,8 +384,8 @@ witness_destroy(struct lock_object *lock) mtx_lock_spin(&w_mtx); w->w_refcount--; if (w->w_refcount == 0) { - CTR1(KTR_WITNESS, - __func__ ": marking witness %s as dead", w->w_name); + CTR2(KTR_WITNESS, + "%s: marking witness %s as dead", __func__, w->w_name); w->w_name = "(dead)"; w->w_file = "(dead)"; w->w_line = 0; @@ -544,7 +544,7 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line) lock1->li_line); panic("recurse"); } - CTR3(KTR_WITNESS, __func__ ": pid %d recursed on %s r=%d", + CTR4(KTR_WITNESS, "%s: pid %d recursed on %s r=%d", __func__, td->td_proc->p_pid, lock->lo_name, lock1->li_flags & LI_RECURSEMASK); lock1->li_file = file; @@ -679,7 +679,7 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line) if (lock == &Giant.mtx_object && (lock1->li_flags & LI_SLEPT) != 0) mtx_unlock_spin(&w_mtx); else { - CTR2(KTR_WITNESS, __func__ ": adding %s as a child of %s", + CTR3(KTR_WITNESS, "%s: adding %s as a child of %s", __func__, lock->lo_name, lock1->li_lock->lo_name); if (!itismychild(lock1->li_lock->lo_witness, w)) mtx_unlock_spin(&w_mtx); @@ -699,7 +699,7 @@ out: if (lle == NULL) return; lle->ll_next = *lock_list; - CTR2(KTR_WITNESS, __func__ ": pid %d added lle %p", + CTR3(KTR_WITNESS, "%s: pid %d added lle %p", __func__, td->td_proc->p_pid, lle); *lock_list = lle; } @@ -711,7 +711,7 @@ out: lock1->li_flags = LI_EXCLUSIVE; else lock1->li_flags = 0; - CTR3(KTR_WITNESS, __func__ ": pid %d added %s as lle[%d]", + CTR4(KTR_WITNESS, "%s: pid %d added %s as lle[%d]", __func__, td->td_proc->p_pid, lock->lo_name, lle->ll_count - 1); } @@ -828,8 +828,8 @@ witness_unlock(struct lock_object *lock, int flags, const char *file, int line) } /* If we are recursed, unrecurse. */ if ((instance->li_flags & LI_RECURSEMASK) > 0) { - CTR3(KTR_WITNESS, - __func__ ": pid %d unrecursed on %s r=%d", + CTR4(KTR_WITNESS, + "%s: pid %d unrecursed on %s r=%d", __func__, td->td_proc->p_pid, instance->li_lock->lo_name, instance->li_flags); @@ -837,8 +837,8 @@ witness_unlock(struct lock_object *lock, int flags, const char *file, int line) goto out; } s = critical_enter(); - CTR3(KTR_WITNESS, - __func__ ": pid %d removed %s from lle[%d]", + CTR4(KTR_WITNESS, + "%s: pid %d removed %s from lle[%d]", __func__, td->td_proc->p_pid, instance->li_lock->lo_name, (*lock_list)->ll_count - 1); @@ -850,8 +850,8 @@ witness_unlock(struct lock_object *lock, int flags, const char *file, int line) if ((*lock_list)->ll_count == 0) { lle = *lock_list; *lock_list = lle->ll_next; - CTR2(KTR_WITNESS, - __func__ ": pid %d removed lle %p", + CTR3(KTR_WITNESS, + "%s: pid %d removed lle %p", __func__, td->td_proc->p_pid, lle); witness_lock_list_free(lle); }