if ((zhp = zpool_open(g_zfs, poolname)) == NULL) {
(void) fprintf(stderr, gettext("cannot open pool '%s'"),
poolname);
+ if (fd != 0)
+ (void) close(fd);
return (1);
}
zpool_close(zhp);
#include <sys/zfs_context.h>
-extern ssize_t lcompat_sprintf(char *, const char *, ...);
+extern ssize_t lcompat_sprintf(char *, size_t size, const char *, ...);
extern int64_t lcompat_strtoll(const char *, char **);
extern int64_t lcompat_pow(int64_t, int64_t);
#define PRId64 "lld"
#endif
-#define LUA_NUMBER_FMT "%" PRId64
-#define lua_number2str(s,n) lcompat_sprintf((s), LUA_NUMBER_FMT, (n))
#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
+#define LUA_NUMBER_FMT "%" PRId64
+#define lua_number2str(s,n) \
+ lcompat_sprintf((s), LUAI_MAXNUMBER2STR, LUA_NUMBER_FMT, (n))
/*
LUA_API void *lua_touserdata (lua_State *L, int idx) {
StkId o = index2addr(L, idx);
switch (ttypenv(o)) {
- case LUA_TUSERDATA: return (rawuvalue(o) + 1);
+ case LUA_TUSERDATA: return ((void *)(rawuvalue(o) + 1));
case LUA_TLIGHTUSERDATA: return pvalue(o);
default: return NULL;
}
ssize_t
-lcompat_sprintf(char *buf, const char *fmt, ...)
+lcompat_sprintf(char *buf, size_t size, const char *fmt, ...)
{
ssize_t res;
va_list args;
va_start(args, fmt);
- res = vsnprintf(buf, INT_MAX, fmt, args);
+ res = vsnprintf(buf, size, fmt, args);
va_end(args);
return (res);
/*
** add 1 to char to allow index -1 (EOZ)
*/
-#define testprop(c,p) (luai_ctype_[(c)+1] & (p))
+#define testprop(c,p) (luai_ctype_[(lu_byte)(c)+1] & (p))
/*
** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_'
expo = "Pp";
for (;;) {
if (check_next(ls, expo)) /* exponent part? */
- check_next(ls, "+-"); /* optional exponent sign */
+ (void) check_next(ls, "+-"); /* optional exponent sign */
if (lisxdigit(ls->current) || ls->current == '.')
save_and_next(ls);
else break;
}
case 'p': {
char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */
- int l = lcompat_sprintf(buff, "%p", va_arg(argp, void *));
+ int l = lcompat_sprintf(buff, sizeof(buff), "%p", va_arg(argp, void *));
pushstr(L, buff, l);
break;
}
}
}
luaK_ret(fs, first, nret);
- testnext(ls, ';'); /* skip optional semicolon */
+ (void) testnext(ls, ';'); /* skip optional semicolon */
}
static TString *createstrobj (lua_State *L, const char *str, size_t l,
int tag, unsigned int h, GCObject **list) {
TString *ts;
+ char *sbuf;
size_t totalsize; /* total size of TString object */
totalsize = sizeof(TString) + ((l + 1) * sizeof(char));
ts = &luaC_newobj(L, tag, totalsize, list, 0)->ts;
ts->tsv.len = l;
ts->tsv.hash = h;
ts->tsv.extra = 0;
- memcpy(ts+1, str, l*sizeof(char));
- ((char *)(ts+1))[l] = '\0'; /* ending 0 */
+ sbuf = (char *)(TString *)(ts + 1);
+ memcpy(sbuf, str, l*sizeof(char));
+ sbuf[l] = '\0'; /* ending 0 */
return ts;
}
TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
Node *mp;
if (ttisnil(key)) luaG_runerror(L, "table index is nil");
+#if defined LUA_HAS_FLOAT_NUMBERS
else if (ttisnumber(key) && luai_numisnan(L, nvalue(key)))
luaG_runerror(L, "table index is NaN");
+#endif
mp = mainposition(t, key);
if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */
Node *othern;
#include "lobject.h"
-#define gnode(t,i) (&(t)->node[i])
+#define gnode(t,i) ((Node *)&(t)->node[i])
#define gkey(n) (&(n)->i_key.tvk)
#define gval(n) (&(n)->i_val)
#define gnext(n) ((n)->i_key.nk.next)
return (err);
hds = ddpa->ddpa_clone;
- snap = list_head(&ddpa->shared_snaps);
- origin_ds = snap->ds;
max_snap_len = MAXNAMELEN - strlen(ddpa->ddpa_clonename) - 1;
- snap = list_head(&ddpa->origin_snaps);
-
if (dsl_dataset_phys(hds)->ds_flags & DS_FLAG_NOPROMOTE) {
promote_rele(ddpa, FTAG);
return (SET_ERROR(EXDEV));
/* compute origin's new unique space */
snap = list_tail(&ddpa->clone_snaps);
+ ASSERT(snap != NULL);
ASSERT3U(dsl_dataset_phys(snap->ds)->ds_prev_snap_obj, ==,
origin_ds->ds_object);
dsl_deadlist_space_range(&snap->ds->ds_deadlist,
{
int error = 0;
objset_t *os;
- uint64_t numval;
+ uint64_t numval = 0;
char *strval = kmem_alloc(ZAP_MAXVALUELEN, KM_SLEEP);
char setpoint[ZFS_MAX_DATASET_NAME_LEN] =
"Internal error - setpoint not determined";
dsl_pool_t *dp = ri->zri_pool;
/* MOS space is triple-dittoed, so we multiply by 3. */
- uint64_t funcspace = (info->blocks_modified << DST_AVG_BLKSHIFT) * 3;
+ uint64_t funcspace =
+ ((uint64_t)info->blocks_modified << DST_AVG_BLKSHIFT) * 3;
zcp_parse_args(state, info->name, info->pargs, info->kwargs);