#define LIBCFS_ALLOC_PRE(size, mask) \
do { \
LASSERT(!in_interrupt() || \
- ((size) <= LIBCFS_VMALLOC_SIZE && \
+ (((size) <= LIBCFS_VMALLOC_SIZE) && \
((mask) & GFP_ATOMIC)) != 0); \
} while (0)
#define LIBCFS_FREE(ptr, size) \
do { \
- int s = (size); \
+ size_t s = (size); \
if (unlikely((ptr) == NULL)) { \
- CERROR("LIBCFS: free NULL '" #ptr "' (%d bytes) at " \
+ CERROR("LIBCFS: free NULL '" #ptr "' (%zd bytes) at " \
"%s:%d\n", s, __FILE__, __LINE__); \
break; \
} \
char kernbuf[16];
int rc;
+ if (len == 0)
+ return -EINVAL;
rc = kstrtoull_from_user(buf, len, 0, &value);
if (rc < 0 && len < sizeof(kernbuf)) {
if (copy_from_user(kernbuf, buf, len))
l = 0;
break;
}
+ /* truncate jobid if it is too long */
+ if (l > joblen)
+ l = joblen;
jobid += l;
joblen -= l;
}
*
* which doesn't work for globally shared files like /last_rcvd.
*/
-static int osd_ldiskfs_readlink(struct inode *inode, char *buffer, int buflen)
+static int osd_ldiskfs_readlink(struct inode *inode, char *buffer,
+ size_t buflen)
{
struct ldiskfs_inode_info *ei = LDISKFS_I(inode);
#define READLINE_BUFFER_INCREMENT 2048
-int readline(int fd, char **buf, int *lenp)
+int readline(int fd, char **buf, ssize_t *lenp)
{
/* read a line into *buf, which is malloced *len long
* realloc if needed until we find a \n
* nul out the \n and return
* 0 of eof, 1 of success
*/
- int len;
+ ssize_t len;
if (*lenp == 0) {
char *b = malloc(READLINE_BUFFER_INCREMENT);
}
len = read(fd, *buf, *lenp);
if (len <= 0) {
- printerr(0, "readline: read error: len %d errno %d (%s)\n",
+ printerr(0, "readline: read error: len %zd errno %d (%s)\n",
len, errno, strerror(errno));
return 0;
}
* so we have to keep reading after re-alloc
*/
char *new;
- int nl;
+ ssize_t nl;
*lenp += READLINE_BUFFER_INCREMENT;
new = realloc(*buf, *lenp);
if (new == NULL)
*buf = new;
nl = read(fd, *buf +len, *lenp - len);
if (nl <= 0 ) {
- printerr(0, "readline: read error: len %d "
+ printerr(0, "readline: read error: len %zd "
"errno %d (%s)\n", nl, errno, strerror(errno));
return 0;
}
len += nl;
}
(*buf)[len-1] = 0;
- printerr(3, "readline: read %d chars into buffer of size %d:\n%s\n",
+ printerr(3, "readline: read %zd chars into buffer of size %zd:\n%s\n",
len, *lenp, *buf);
return 1;
}
int qword_printhex(FILE *f, char *str, int slen);
void qword_printint(FILE *f, int num);
int qword_eol(FILE *f);
-int readline(int fd, char **buf, int *lenp);
+int readline(int fd, char **buf, ssize_t *lenp);
int qword_get(char **bpp, char *dest, int bufsize);
int qword_get_int(char **bpp, int *anint);
char out_handle_buf[15];
uint32_t lustre_mech;
static char *lbuf;
- static int lbuflen;
+ static ssize_t lbuflen;
static char *cp;
int get_len;
int rc;
struct llog_rec_hdr ***recs,
int *recs_number)
{
- int rc = 0, recs_num, rd = 0;
+ ssize_t rd = 0;
+ ssize_t nbytes;
+ int rc = 0, recs_num;
long long file_size;
struct stat st;
char *file_buf = NULL, *recs_buf = NULL;
*llog = (struct llog_log_hdr *)file_buf;
do {
- rc = read(fd, file_buf + rd, file_size - rd);
- if (rc > 0)
- rd += rc;
- } while (rc > 0 && rd < file_size);
+ nbytes = read(fd, file_buf + rd, file_size - rd);
+ if (nbytes > 0)
+ rd += nbytes;
+ } while (nbytes > 0 && rd < file_size);
if (rd < file_size) {
rc = rc < 0 ? -errno : -EIO;
llapi_error(LLAPI_MSG_ERROR, rc,
- "Error reading llog header: need %zd, got %d",
+ "Error reading llog header: need %zd, got %zd",
sizeof(**llog), rd);
goto clear_file_buf;
}