* GCC doesn't understand the (arguably complex) control flow in * this function and complains about uninitialized structure fields * without this. */ memset(&nrec, 0, sizeof(nrec));  /* 
xfs_inobt_insrec(	xfs_btree_cur_t		*cur,	/* btree cursor */	int			level,	/* level to insert record at */	xfs_agblock_t		*bnop,	/* i/o: block number inserted */	xfs_inobt_rec_t		*recp,	/* i/o: record data inserted */	xfs_btree_cur_t		**curp,	/* output: new cursor replacing cur */	int			*stat)	/* success/failure */{	xfs_inobt_block_t	*block;	/* btree block record/key lives in */	xfs_buf_t		*bp;	/* buffer for block */	int			error;	/* error return value */	int			i;	/* loop index */	xfs_inobt_key_t		key;	/* key value being inserted */	xfs_inobt_key_t		*kp=NULL;	/* pointer to btree keys */	xfs_agblock_t		nbno;	/* block number of allocated block */	xfs_btree_cur_t		*ncur;	/* new cursor to be used at next lvl */	xfs_inobt_key_t		nkey;	/* new key value, from split */	xfs_inobt_rec_t		nrec;	/* new record value, for caller */	int			numrecs;	int			optr;	/* old ptr value */	xfs_inobt_ptr_t		*pp;	/* pointer to btree addresses */	int			ptr;	/* index in btree block for this rec */	xfs_inobt_rec_t		*rp=NULL;	/* pointer to btree records */	/*	 * If we made it to the root level, allocate a new root block	 * and we're done.	 */	if (level >= cur->bc_nlevels) {		error = xfs_inobt_newroot(cur, &i);		*bnop = NULLAGBLOCK;		*stat = i;		return error;	}	/*	 * Make a key out of the record data to be inserted, and save it.	 */	key.ir_startino = recp->ir_startino; /* INT_: direct copy */	optr = ptr = cur->bc_ptrs[level];	/*	 * If we're off the left edge, return failure.	 */	if (ptr == 0) {		*stat = 0;		return 0;	}	/*	 * Get pointers to the btree buffer and block.	 */	bp = cur->bc_bufs[level];	block = XFS_BUF_TO_INOBT_BLOCK(bp);	numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT);#ifdef DEBUG	if ((error = xfs_btree_check_sblock(cur, block, level, bp)))		return error;	/*	 * Check that the new entry is being inserted in the right place.	 */	if (ptr <= numrecs) {		if (level == 0) {			rp = XFS_INOBT_REC_ADDR(block, ptr, cur);			xfs_btree_check_rec(cur->bc_btnum, recp, rp);		} else {			kp = XFS_INOBT_KEY_ADDR(block, ptr, cur);			xfs_btree_check_key(cur->bc_btnum, &key, kp);		}	}#endif	nbno = NULLAGBLOCK;	ncur = (xfs_btree_cur_t *)0;	/*	 * If the block is full, we can't insert the new entry until we	 * make the block un-full.	 */	if (numrecs == XFS_INOBT_BLOCK_MAXRECS(level, cur)) {		/*		 * First, try shifting an entry to the right neighbor.		 */		if ((error = xfs_inobt_rshift(cur, level, &i)))			return error;		if (i) {			/* nothing */		}		/*		 * Next, try shifting an entry to the left neighbor.		 */		else {			if ((error = xfs_inobt_lshift(cur, level, &i)))				return error;			if (i) {				optr = ptr = cur->bc_ptrs[level];			} else {				/*				 * Next, try splitting the current block				 * in half. If this works we have to				 * re-set our variables because				 * we could be in a different block now.				 */				if ((error = xfs_inobt_split(cur, level, &nbno,						&nkey, &ncur, &i)))					return error;				if (i) {					bp = cur->bc_bufs[level];					block = XFS_BUF_TO_INOBT_BLOCK(bp);#ifdef DEBUG					if ((error = xfs_btree_check_sblock(cur,							block, level, bp)))						return error;#endif					ptr = cur->bc_ptrs[level];					nrec.ir_startino = nkey.ir_startino; /* INT_: direct copy */				} else {					/*					 * Otherwise the insert fails.					 */					*stat = 0;					return 0;				}			}		}	}	/*	 * At this point we know there's room for our new entry in the block	 * we're pointing at.	 */	numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT);	if (level > 0) {		/*		 * It's a non-leaf entry.  Make a hole for the new data		 * in the key and ptr regions of the block.		 */		kp = XFS_INOBT_KEY_ADDR(block, 1, cur);		pp = XFS_INOBT_PTR_ADDR(block, 1, cur);#ifdef DEBUG		for (i = numrecs; i >= ptr; i--) {			if ((error = xfs_btree_check_sptr(cur, INT_GET(pp[i - 1], ARCH_CONVERT), level)))				return error;		}#endif		memmove(&kp[ptr], &kp[ptr - 1],			(numrecs - ptr + 1) * sizeof(*kp));		memmove(&pp[ptr], &pp[ptr - 1],			(numrecs - ptr + 1) * sizeof(*pp));		/*		 * Now stuff the new data in, bump numrecs and log the new data.		 */#ifdef DEBUG		if ((error = xfs_btree_check_sptr(cur, *bnop, level)))			return error;#endif		kp[ptr - 1] = key; /* INT_: struct copy */		INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop);		numrecs++;		INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs);		xfs_inobt_log_keys(cur, bp, ptr, numrecs);		xfs_inobt_log_ptrs(cur, bp, ptr, numrecs);	} else {		/*		 * It's a leaf entry.  Make a hole for the new record.		 */		rp = XFS_INOBT_REC_ADDR(block, 1, cur);		memmove(&rp[ptr], &rp[ptr - 1],			(numrecs - ptr + 1) * sizeof(*rp));		/*		 * Now stuff the new record in, bump numrecs		 * and log the new data.		 */		rp[ptr - 1] = *recp; /* INT_: struct copy */		numrecs++;		INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs);		xfs_inobt_log_recs(cur, bp, ptr, numrecs);	}	/*	 * Log the new number of records in the btree header.	 */	xfs_inobt_log_block(cur->bc_tp, bp, XFS_BB_NUMRECS);#ifdef DEBUG	/*	 * Check that the key/record is in the right place, now.	 */	if (ptr < numrecs) {		if (level == 0)			xfs_btree_check_rec(cur->bc_btnum, rp + ptr - 1,				rp + ptr);		else			xfs_btree_check_key(cur->bc_btnum, kp + ptr - 1,				kp + ptr);	}#endif	/*	 * If we inserted at the start of a block, update the parents' keys.	 */	if (optr == 1 && (error = xfs_inobt_updkey(cur, &key, level + 1)))		return error;	/*	 * Return the new block number, if any.	 * If there is one, give back a record value and a cursor too.	 */	*bnop = nbno;	if (nbno != NULLAGBLOCK) {		*recp = nrec; /* INT_: struct copy */		*curp = ncur;	}	*stat = 1;	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/5bde1ba99c8243617277f37897189c799e398baf/xfs_ialloc_btree.c/clean/fs/xfs/xfs_ialloc_btree.c