From 0d2f84e117e06db09414ec55b0c0c79f3e8c7bdb Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 28 Oct 2008 14:42:31 +0000 Subject: (svn r14540) -Codechange: introduce [v]seprintf which are like [v]snprintf but do return the number of characters written instead of the number of characters that would be written; as size_t is unsigned substraction can cause integer underflows quite quickly. --- src/driver.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/driver.cpp') diff --git a/src/driver.cpp b/src/driver.cpp index b042ea620..dc8ffb1af 100644 --- a/src/driver.cpp +++ b/src/driver.cpp @@ -168,7 +168,7 @@ void DriverFactoryBase::RegisterDriver(const char *name, Driver::Type type, int char *DriverFactoryBase::GetDriversInfo(char *p, const char *last) { for (Driver::Type type = Driver::DT_BEGIN; type != Driver::DT_END; type++) { - p += snprintf(p, last - p, "List of %s drivers:\n", GetDriverTypeName(type)); + p += seprintf(p, last, "List of %s drivers:\n", GetDriverTypeName(type)); for (int priority = 10; priority >= 0; priority--) { Drivers::iterator it = GetDrivers().begin(); @@ -176,11 +176,11 @@ char *DriverFactoryBase::GetDriversInfo(char *p, const char *last) DriverFactoryBase *d = (*it).second; if (d->type != type) continue; if (d->priority != priority) continue; - p += snprintf(p, last - p, "%18s: %s\n", d->name, d->GetDescription()); + p += seprintf(p, last, "%18s: %s\n", d->name, d->GetDescription()); } } - p += snprintf(p, last - p, "\n"); + p += seprintf(p, last, "\n"); } return p; -- cgit v1.2.3-70-g09d2