ret = snprintf(lockfile_name.buf, sizeof(lockfile_name.buf),
"%s/%u", ctx->lockfile_dir.buf, (unsigned)pid);
- if (ret >= sizeof(lockfile_name.buf)) {
+ if (ret < 0) {
+ return errno;
+ }
+ if ((unsigned)ret >= sizeof(lockfile_name.buf)) {
return ENAMETOOLONG;
}
ret = snprintf(name.buf, sizeof(name.buf), "%s/%u",
c->lockfile_dir.buf, (unsigned)c->pid);
- if (ret >= sizeof(name.buf)) {
+ if ((ret < 0) || ((size_t)ret >= sizeof(name.buf))) {
/*
* We've checked the length when creating, so this
* should never happen
dst_pathlen = snprintf(dst.sun_path, sizeof(dst.sun_path),
"%s/%u", ctx->socket_dir.buf, (unsigned)pid);
- if (dst_pathlen >= sizeof(dst.sun_path)) {
+ if (dst_pathlen < 0) {
+ return errno;
+ }
+ if ((size_t)dst_pathlen >= sizeof(dst.sun_path)) {
return ENAMETOOLONG;
}
ret = snprintf(lockfile_name.buf, sizeof(lockfile_name.buf),
"%s/%u", ctx->lockfile_dir.buf, (int)pid);
- if (ret >= sizeof(lockfile_name.buf)) {
+ if (ret < 0) {
+ return errno;
+ }
+ if ((size_t)ret >= sizeof(lockfile_name.buf)) {
return ENAMETOOLONG;
}
len = snprintf(socket_name.buf, sizeof(socket_name.buf), "%s/%u",
ctx->socket_dir.buf, (unsigned)pid);
- if (len >= sizeof(socket_name.buf)) {
+ if (len < 0) {
+ return errno;
+ }
+ if ((size_t)len >= sizeof(socket_name.buf)) {
return ENAMETOOLONG;
}
len = snprintf(lockfile_name.buf, sizeof(lockfile_name.buf), "%s/%u",
ctx->lockfile_dir.buf, (unsigned)pid);
- if (len >= sizeof(lockfile_name.buf)) {
+ if (len < 0) {
+ return errno;
+ }
+ if ((size_t)len >= sizeof(lockfile_name.buf)) {
return ENAMETOOLONG;
}
*/
continue;
}
- if (pid == our_pid) {
+ if ((pid_t)pid == our_pid) {
/*
* fcntl(F_GETLK) will succeed for ourselves, we hold
* that lock ourselves.