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.
This commit is contained in:
obrien 2001-12-10 05:40:12 +00:00
parent cf805be425
commit 27c7141d5b
4 changed files with 38 additions and 38 deletions

View File

@ -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);

View File

@ -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 @@ ithread_loop(void *arg)
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 @@ ithread_loop(void *arg)
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);
}

View File

@ -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);
}

View File

@ -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 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line)
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 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line)
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);
}