idx
int64 | func
string | target
int64 |
|---|---|---|
226,392
|
void esds_box_del(GF_Box *s)
{
GF_ESDBox *ptr = (GF_ESDBox *)s;
if (ptr == NULL) return;
if (ptr->desc) gf_odf_desc_del((GF_Descriptor *)ptr->desc);
gf_free(ptr);
}
| 0
|
229,154
|
static void set_status(VirtIODevice *vdev, uint8_t status)
{
VirtIOSerial *vser;
VirtIOSerialPort *port;
vser = VIRTIO_SERIAL(vdev);
port = find_port_by_id(vser, 0);
if (port && !use_multiport(port->vser)
&& (status & VIRTIO_CONFIG_S_DRIVER_OK)) {
/*
* Non-multiport guests won't be able to tell us guest
* open/close status. Such guests can only have a port at id
* 0, so set guest_connected for such ports as soon as guest
* is up.
*/
port->guest_connected = true;
}
if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) {
guest_reset(vser);
}
}
| 0
|
195,302
|
R_API bool r_io_bank_map_add_top(RIO *io, const ut32 bankid, const ut32 mapid) {
RIOBank *bank = r_io_bank_get (io, bankid);
RIOMap *map = r_io_map_get (io, mapid);
r_return_val_if_fail (io && bank && map, false);
RIOMapRef *mapref = _mapref_from_map (map);
if (!mapref) {
return false;
}
RIOSubMap *sm = r_io_submap_new (io, mapref);
if (!sm) {
free (mapref);
return false;
}
RRBNode *entry = _find_entry_submap_node (bank, sm);
if (!entry) {
// no intersection with any submap, so just insert
if (!r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL)) {
free (sm);
free (mapref);
return false;
}
r_list_append (bank->maprefs, mapref);
return true;
}
bank->last_used = NULL;
RIOSubMap *bd = (RIOSubMap *)entry->data;
if (r_io_submap_to (bd) == r_io_submap_to (sm) &&
r_io_submap_from (bd) >= r_io_submap_from (sm)) {
// _find_entry_submap_node guarantees, that there is no submap
// prior to bd in the range of sm, so instead of deleting and inserting
// we can just memcpy
memcpy (bd, sm, sizeof (RIOSubMap));
free (sm);
r_list_append (bank->maprefs, mapref);
return true;
}
if (r_io_submap_from (bd) < r_io_submap_from (sm) &&
r_io_submap_to (sm) < r_io_submap_to (bd)) {
// split bd into 2 maps => bd and bdsm
RIOSubMap *bdsm = R_NEWCOPY (RIOSubMap, bd);
if (!bdsm) {
free (sm);
free (mapref);
return false;
}
r_io_submap_set_from (bdsm, r_io_submap_to (sm) + 1);
r_io_submap_set_to (bd, r_io_submap_from (sm) - 1);
// TODO: insert and check return value, before adjusting sm size
if (!r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL)) {
free (sm);
free (bdsm);
free (mapref);
return false;
}
if (!r_crbtree_insert (bank->submaps, bdsm, _find_sm_by_from_vaddr_cb, NULL)) {
r_crbtree_delete (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL);
free (sm);
free (bdsm);
free (mapref);
return false;
}
r_list_append (bank->maprefs, mapref);
return true;
}
// guaranteed intersection
if (r_io_submap_from (bd) < r_io_submap_from (sm)) {
r_io_submap_set_to (bd, r_io_submap_from (sm) - 1);
entry = r_rbnode_next (entry);
}
while (entry && r_io_submap_to (((RIOSubMap *)entry->data)) <= r_io_submap_to (sm)) {
//delete all submaps that are completly included in sm
RRBNode *next = r_rbnode_next (entry);
// this can be optimized, there is no need to do search here
r_crbtree_delete (bank->submaps, entry->data, _find_sm_by_from_vaddr_cb, NULL);
entry = next;
}
if (entry && r_io_submap_from (((RIOSubMap *)entry->data)) <= r_io_submap_to (sm)) {
bd = (RIOSubMap *)entry->data;
r_io_submap_set_from (bd, r_io_submap_to (sm) + 1);
}
if (!r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL)) {
free (sm);
free (mapref);
return false;
}
r_list_append (bank->maprefs, mapref);
return true;
}
| 1
|
512,527
|
Field *create_tmp_field_ex(TABLE *table, Tmp_field_src *src,
const Tmp_field_param *param)
{
return Item_type_holder::real_type_handler()->
make_and_init_table_field(&name, Record_addr(maybe_null),
*this, table);
}
| 0
|
313,541
|
static void rose_remove_node(struct rose_node *rose_node)
{
struct rose_node *s;
if ((s = rose_node_list) == rose_node) {
rose_node_list = rose_node->next;
kfree(rose_node);
return;
}
while (s != NULL && s->next != NULL) {
if (s->next == rose_node) {
s->next = rose_node->next;
kfree(rose_node);
return;
}
s = s->next;
}
}
| 0
|
231,793
|
TEST_F(QuicServerTransportTest, IdleTimerNotResetOnDuplicatePacket) {
EXPECT_CALL(*transportInfoCb_, onNewQuicStream()).Times(1);
StreamId streamId = server->createBidirectionalStream().value();
auto expected = IOBuf::copyBuffer("hello");
auto packet = recvEncryptedStream(streamId, *expected);
ASSERT_TRUE(server->idleTimeout().isScheduled());
server->idleTimeout().cancelTimeout();
ASSERT_FALSE(server->idleTimeout().isScheduled());
// Try delivering the same packet again
deliverData(packet->clone(), false);
ASSERT_FALSE(server->idleTimeout().isScheduled());
EXPECT_CALL(*transportInfoCb_, onQuicStreamClosed());
}
| 0
|
300,785
|
static int tipc_recvmsg(struct socket *sock, struct msghdr *m,
size_t buflen, int flags)
{
struct sock *sk = sock->sk;
bool connected = !tipc_sk_type_connectionless(sk);
struct tipc_sock *tsk = tipc_sk(sk);
int rc, err, hlen, dlen, copy;
struct tipc_skb_cb *skb_cb;
struct sk_buff_head xmitq;
struct tipc_msg *hdr;
struct sk_buff *skb;
bool grp_evt;
long timeout;
/* Catch invalid receive requests */
if (unlikely(!buflen))
return -EINVAL;
lock_sock(sk);
if (unlikely(connected && sk->sk_state == TIPC_OPEN)) {
rc = -ENOTCONN;
goto exit;
}
timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
/* Step rcv queue to first msg with data or error; wait if necessary */
do {
rc = tipc_wait_for_rcvmsg(sock, &timeout);
if (unlikely(rc))
goto exit;
skb = skb_peek(&sk->sk_receive_queue);
skb_cb = TIPC_SKB_CB(skb);
hdr = buf_msg(skb);
dlen = msg_data_sz(hdr);
hlen = msg_hdr_sz(hdr);
err = msg_errcode(hdr);
grp_evt = msg_is_grp_evt(hdr);
if (likely(dlen || err))
break;
tsk_advance_rx_queue(sk);
} while (1);
/* Collect msg meta data, including error code and rejected data */
tipc_sk_set_orig_addr(m, skb);
rc = tipc_sk_anc_data_recv(m, skb, tsk);
if (unlikely(rc))
goto exit;
hdr = buf_msg(skb);
/* Capture data if non-error msg, otherwise just set return value */
if (likely(!err)) {
int offset = skb_cb->bytes_read;
copy = min_t(int, dlen - offset, buflen);
rc = skb_copy_datagram_msg(skb, hlen + offset, m, copy);
if (unlikely(rc))
goto exit;
if (unlikely(offset + copy < dlen)) {
if (flags & MSG_EOR) {
if (!(flags & MSG_PEEK))
skb_cb->bytes_read = offset + copy;
} else {
m->msg_flags |= MSG_TRUNC;
skb_cb->bytes_read = 0;
}
} else {
if (flags & MSG_EOR)
m->msg_flags |= MSG_EOR;
skb_cb->bytes_read = 0;
}
} else {
copy = 0;
rc = 0;
if (err != TIPC_CONN_SHUTDOWN && connected && !m->msg_control) {
rc = -ECONNRESET;
goto exit;
}
}
/* Mark message as group event if applicable */
if (unlikely(grp_evt)) {
if (msg_grp_evt(hdr) == TIPC_WITHDRAWN)
m->msg_flags |= MSG_EOR;
m->msg_flags |= MSG_OOB;
copy = 0;
}
/* Caption of data or error code/rejected data was successful */
if (unlikely(flags & MSG_PEEK))
goto exit;
/* Send group flow control advertisement when applicable */
if (tsk->group && msg_in_group(hdr) && !grp_evt) {
__skb_queue_head_init(&xmitq);
tipc_group_update_rcv_win(tsk->group, tsk_blocks(hlen + dlen),
msg_orignode(hdr), msg_origport(hdr),
&xmitq);
tipc_node_distr_xmit(sock_net(sk), &xmitq);
}
if (skb_cb->bytes_read)
goto exit;
tsk_advance_rx_queue(sk);
if (likely(!connected))
goto exit;
/* Send connection flow control advertisement when applicable */
tsk->rcv_unacked += tsk_inc(tsk, hlen + dlen);
if (tsk->rcv_unacked >= tsk->rcv_win / TIPC_ACK_RATE)
tipc_sk_send_ack(tsk);
exit:
release_sock(sk);
return rc ? rc : copy;
}
| 0
|
90,179
|
virtual void RemoveObserverForAllNetworks(NetworkObserver* observer) {}
| 0
|
439,150
|
ModuleExport size_t RegisterICONImage(void)
{
MagickInfo
*entry;
entry=SetMagickInfo("CUR");
entry->decoder=(DecodeImageHandler *) ReadICONImage;
entry->encoder=(EncodeImageHandler *) WriteICONImage;
entry->adjoin=MagickFalse;
entry->seekable_stream=MagickTrue;
entry->description=ConstantString("Microsoft icon");
entry->module=ConstantString("ICON");
(void) RegisterMagickInfo(entry);
entry=SetMagickInfo("ICO");
entry->decoder=(DecodeImageHandler *) ReadICONImage;
entry->encoder=(EncodeImageHandler *) WriteICONImage;
entry->adjoin=MagickTrue;
entry->seekable_stream=MagickTrue;
entry->description=ConstantString("Microsoft icon");
entry->module=ConstantString("ICON");
(void) RegisterMagickInfo(entry);
entry=SetMagickInfo("ICON");
entry->decoder=(DecodeImageHandler *) ReadICONImage;
entry->encoder=(EncodeImageHandler *) WriteICONImage;
entry->adjoin=MagickFalse;
entry->seekable_stream=MagickTrue;
entry->description=ConstantString("Microsoft icon");
entry->module=ConstantString("ICON");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
| 0
|
413,582
|
static void add_single_addr_xrefs(RCore *core, ut64 addr, RGraph *graph) {
r_return_if_fail (graph);
RFlagItem *f = r_flag_get_at (core->flags, addr, false);
char *me = (f && f->offset == addr)
? r_str_new (f->name)
: r_str_newf ("0x%" PFMT64x, addr);
RGraphNode *curr_node = r_graph_add_node_info (graph, me, NULL, addr);
R_FREE (me);
if (!curr_node) {
return;
}
RListIter *iter;
RAnalRef *ref;
RList *list = r_anal_xrefs_get (core->anal, addr);
r_list_foreach (list, iter, ref) {
RFlagItem *item = r_flag_get_i (core->flags, ref->addr);
char *src = item? r_str_new (item->name): r_str_newf ("0x%08" PFMT64x, ref->addr);
RGraphNode *reference_from = r_graph_add_node_info (graph, src, NULL, ref->addr);
free (src);
r_graph_add_edge (graph, reference_from, curr_node);
}
r_list_free (list);
}
| 0
|
404,740
|
__acquires(files->file_lock)
{
struct fdtable *new_fdt, *cur_fdt;
spin_unlock(&files->file_lock);
new_fdt = alloc_fdtable(nr);
/* make sure all fd_install() have seen resize_in_progress
* or have finished their rcu_read_lock_sched() section.
*/
if (atomic_read(&files->count) > 1)
synchronize_rcu();
spin_lock(&files->file_lock);
if (!new_fdt)
return -ENOMEM;
/*
* extremely unlikely race - sysctl_nr_open decreased between the check in
* caller and alloc_fdtable(). Cheaper to catch it here...
*/
if (unlikely(new_fdt->max_fds <= nr)) {
__free_fdtable(new_fdt);
return -EMFILE;
}
cur_fdt = files_fdtable(files);
BUG_ON(nr < cur_fdt->max_fds);
copy_fdtable(new_fdt, cur_fdt);
rcu_assign_pointer(files->fdt, new_fdt);
if (cur_fdt != &files->fdtab)
call_rcu(&cur_fdt->rcu, free_fdtable_rcu);
/* coupled with smp_rmb() in fd_install() */
smp_wmb();
return 1;
}
| 0
|
434,104
|
do_one_arg(char_u *str)
{
char_u *p;
int inbacktick;
inbacktick = FALSE;
for (p = str; *str; ++str)
{
// When the backslash is used for escaping the special meaning of a
// character we need to keep it until wildcard expansion.
if (rem_backslash(str))
{
*p++ = *str++;
*p++ = *str;
}
else
{
// An item ends at a space not in backticks
if (!inbacktick && vim_isspace(*str))
break;
if (*str == '`')
inbacktick ^= TRUE;
*p++ = *str;
}
}
str = skipwhite(str);
*p = NUL;
return str;
}
| 0
|
338,231
|
void WasmBinaryWriter::writeField(const Field& field) {
if (field.type == Type::i32 && field.packedType != Field::not_packed) {
if (field.packedType == Field::i8) {
o << S32LEB(BinaryConsts::EncodedType::i8);
} else if (field.packedType == Field::i16) {
o << S32LEB(BinaryConsts::EncodedType::i16);
} else {
WASM_UNREACHABLE("invalid packed type");
}
} else {
writeType(field.type);
}
o << U32LEB(field.mutable_);
}
| 0
|
463,055
|
static void sungem_mmio_txdma_write(void *opaque, hwaddr addr, uint64_t val,
unsigned size)
{
SunGEMState *s = opaque;
if (!(addr < 0x38) && !(addr >= 0x100 && addr <= 0x118)) {
qemu_log_mask(LOG_GUEST_ERROR,
"Write to unknown TXDMA register 0x%"HWADDR_PRIx"\n",
addr);
return;
}
trace_sungem_mmio_txdma_write(addr, val);
/* Pre-write filter */
switch (addr) {
/* Read only registers */
case TXDMA_TXDONE:
case TXDMA_PCNT:
case TXDMA_SMACHINE:
case TXDMA_DPLOW:
case TXDMA_DPHI:
case TXDMA_FSZ:
case TXDMA_FTAG:
return; /* No actual write */
}
s->txdmaregs[addr >> 2] = val;
/* Post write action */
switch (addr) {
case TXDMA_KICK:
sungem_tx_kick(s);
break;
case TXDMA_CFG:
sungem_update_masks(s);
break;
}
}
| 0
|
411,903
|
_find_by_keyword(smartlist_t *s, directory_keyword keyword,
const char *keyword_as_string)
{
directory_token_t *tok = find_opt_by_keyword(s, keyword);
if (PREDICT_UNLIKELY(!tok)) {
log_err(LD_BUG, "Missing %s [%d] in directory object that should have "
"been validated. Internal error.", keyword_as_string, (int)keyword);
tor_assert(tok);
}
return tok;
}
| 0
|
225,828
|
GF_Err edts_box_write(GF_Box *s, GF_BitStream *bs)
{
GF_EditBox *ptr = (GF_EditBox *)s;
//here we have a trick: if editList is empty, skip the box
if (ptr->editList && gf_list_count(ptr->editList->entryList)) {
return gf_isom_box_write_header(s, bs);
} else {
s->size = 0;
}
return GF_OK;
}
| 0
|
202,392
|
static inline LineContribType * _gdContributionsAlloc(unsigned int line_length, unsigned int windows_size)
{
unsigned int u = 0;
LineContribType *res;
int overflow_error = 0;
res = (LineContribType *) gdMalloc(sizeof(LineContribType));
if (!res) {
return NULL;
}
res->WindowSize = windows_size;
res->LineLength = line_length;
if (overflow2(line_length, sizeof(ContributionType))) {
gdFree(res);
return NULL;
}
res->ContribRow = (ContributionType *) gdMalloc(line_length * sizeof(ContributionType));
if (res->ContribRow == NULL) {
gdFree(res);
return NULL;
}
for (u = 0 ; u < line_length ; u++) {
if (overflow2(windows_size, sizeof(double))) {
overflow_error = 1;
} else {
res->ContribRow[u].Weights = (double *) gdMalloc(windows_size * sizeof(double));
}
if (overflow_error == 1 || res->ContribRow[u].Weights == NULL) {
u--;
while (u >= 0) {
gdFree(res->ContribRow[u].Weights);
u--;
}
return NULL;
}
}
return res;
}
| 1
|
282,885
|
int rsi_band_check(struct rsi_common *common,
struct ieee80211_channel *curchan)
{
struct rsi_hw *adapter = common->priv;
struct ieee80211_hw *hw = adapter->hw;
u8 prev_bw = common->channel_width;
u8 prev_ep = common->endpoint;
int status = 0;
if (common->band != curchan->band) {
common->rf_reset = 1;
common->band = curchan->band;
}
if ((hw->conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT) ||
(hw->conf.chandef.width == NL80211_CHAN_WIDTH_20))
common->channel_width = BW_20MHZ;
else
common->channel_width = BW_40MHZ;
if (common->band == NL80211_BAND_2GHZ) {
if (common->channel_width)
common->endpoint = EP_2GHZ_40MHZ;
else
common->endpoint = EP_2GHZ_20MHZ;
} else {
if (common->channel_width)
common->endpoint = EP_5GHZ_40MHZ;
else
common->endpoint = EP_5GHZ_20MHZ;
}
if (common->endpoint != prev_ep) {
status = rsi_program_bb_rf(common);
if (status)
return status;
}
if (common->channel_width != prev_bw) {
if (adapter->device_model == RSI_DEV_9116)
status = rsi_load_9116_bootup_params(common);
else
status = rsi_load_bootup_params(common);
if (status)
return status;
status = rsi_load_radio_caps(common);
if (status)
return status;
}
return status;
}
| 0
|
248,282
|
DLLIMPORT char *cfg_getstr(cfg_t *cfg, const char *name)
{
return cfg_getnstr(cfg, name, 0);
}
| 0
|
317,102
|
static int smack_ipc_alloc_security(struct kern_ipc_perm *isp)
{
struct smack_known **blob = smack_ipc(isp);
*blob = smk_of_current();
return 0;
}
| 0
|
220,832
|
inline int SubscriptToIndex(const NdArrayDesc<4>& desc, int i0, int i1, int i2,
int i3) {
TFLITE_DCHECK(i0 >= 0 && i0 < desc.extents[0]);
TFLITE_DCHECK(i1 >= 0 && i1 < desc.extents[1]);
TFLITE_DCHECK(i2 >= 0 && i2 < desc.extents[2]);
TFLITE_DCHECK(i3 >= 0 && i3 < desc.extents[3]);
return i0 * desc.strides[0] + i1 * desc.strides[1] + i2 * desc.strides[2] +
i3 * desc.strides[3];
}
| 0
|
225,718
|
GF_Err gen_sample_entry_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_Err e = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)s, bs);
if (e) return e;
ISOM_DECREASE_SIZE(s, 8);
return gf_isom_box_array_read(s, bs);
}
| 0
|
455,312
|
bash_progcomp_ignore_filenames (names)
char **names;
{
_ignore_completion_names (names, test_for_canon_directory);
return 0;
}
| 0
|
361,747
|
static void em28xx_release_resources(struct em28xx *dev)
{
struct usb_device *udev = interface_to_usbdev(dev->intf);
/*FIXME: I2C IR should be disconnected */
mutex_lock(&dev->lock);
em28xx_unregister_media_device(dev);
if (dev->def_i2c_bus)
em28xx_i2c_unregister(dev, 1);
em28xx_i2c_unregister(dev, 0);
if (dev->ts == PRIMARY_TS)
usb_put_dev(udev);
/* Mark device as unused */
clear_bit(dev->devno, em28xx_devused);
mutex_unlock(&dev->lock);
};
| 0
|
274,678
|
callbacks_layer_tree_visibility_toggled (gint index)
{
mainProject->file[index]->isVisible =
!mainProject->file[index]->isVisible;
callbacks_update_layer_tree ();
if (screenRenderInfo.renderType <= GERBV_RENDER_TYPE_GDK_XOR) {
render_refresh_rendered_image_on_screen ();
} else {
render_recreate_composite_surface (screen.drawing_area);
callbacks_force_expose_event_for_screen ();
}
}
| 0
|
353,145
|
void SplashOutputDev::saveState(GfxState *state) {
splash->saveState();
if (t3GlyphStack && !t3GlyphStack->haveDx) {
t3GlyphStack->doNotCache = true;
error(errSyntaxWarning, -1,
"Save (q) operator before d0/d1 in Type 3 glyph");
}
}
| 0
|
453,034
|
void nft_immediate_eval(const struct nft_expr *expr,
struct nft_regs *regs,
const struct nft_pktinfo *pkt)
{
const struct nft_immediate_expr *priv = nft_expr_priv(expr);
nft_data_copy(®s->data[priv->dreg], &priv->data, priv->dlen);
}
| 0
|
267,985
|
static int string_scan_range(RList *list, RBinFile *bf, int min,
const ut64 from, const ut64 to, int type, int raw, RBinSection *section) {
RBin *bin = bf->rbin;
ut8 tmp[R_STRING_SCAN_BUFFER_SIZE];
ut64 str_start, needle = from;
int count = 0, i, rc, runes;
int str_type = R_STRING_TYPE_DETECT;
// if list is null it means its gonna dump
r_return_val_if_fail (bf, -1);
if (type == -1) {
type = R_STRING_TYPE_DETECT;
}
if (from == to) {
return 0;
}
if (from > to) {
eprintf ("Invalid range to find strings 0x%"PFMT64x" .. 0x%"PFMT64x"\n", from, to);
return -1;
}
st64 len = (st64)(to - from);
if (len < 1 || len > ST32_MAX) {
eprintf ("String scan range is invalid (%"PFMT64d" bytes)\n", len);
return -1;
}
ut8 *buf = calloc (len, 1);
if (!buf || !min) {
free (buf);
return -1;
}
st64 vdelta = 0, pdelta = 0;
RBinSection *s = NULL;
bool ascii_only = false;
PJ *pj = NULL;
if (bf->strmode == R_MODE_JSON && !list) {
pj = pj_new ();
if (pj) {
pj_a (pj);
}
}
r_buf_read_at (bf->buf, from, buf, len);
char *charset = r_sys_getenv ("RABIN2_CHARSET");
if (!R_STR_ISEMPTY (charset)) {
RCharset *ch = r_charset_new ();
if (r_charset_use (ch, charset)) {
int outlen = len * 4;
ut8 *out = calloc (len, 4);
if (out) {
int res = r_charset_encode_str (ch, out, outlen, buf, len);
int i;
// TODO unknown chars should be translated to null bytes
for (i = 0; i < res; i++) {
if (out[i] == '?') {
out[i] = 0;
}
}
len = res;
free (buf);
buf = out;
} else {
eprintf ("Cannot allocate\n");
}
} else {
eprintf ("Invalid value for RABIN2_CHARSET.\n");
}
r_charset_free (ch);
}
free (charset);
RConsIsBreaked is_breaked = (bin && bin->consb.is_breaked)? bin->consb.is_breaked: NULL;
// may oobread
while (needle < to && needle < UT64_MAX - 4) {
if (is_breaked && is_breaked ()) {
break;
}
// smol optimization
if (needle < to - 4) {
ut32 n1 = r_read_le32 (buf + (needle - from));
if (!n1) {
needle += 4;
continue;
}
}
rc = r_utf8_decode (buf + (needle - from), to - needle, NULL);
if (!rc) {
needle++;
continue;
}
bool addr_aligned = !(needle % 4);
if (type == R_STRING_TYPE_DETECT) {
char *w = (char *)buf + (needle + rc - from);
if (((to - needle) > 8 + rc)) {
// TODO: support le and be
bool is_wide32le = (needle + rc + 2 < to) && (!w[0] && !w[1] && !w[2] && w[3] && !w[4]);
// reduce false positives
if (is_wide32le) {
if (!w[5] && !w[6] && w[7] && w[8]) {
is_wide32le = false;
}
}
if (!addr_aligned) {
is_wide32le = false;
}
///is_wide32be &= (n1 < 0xff && n11 < 0xff); // false; // n11 < 0xff;
if (is_wide32le && addr_aligned) {
str_type = R_STRING_TYPE_WIDE32; // asume big endian,is there little endian w32?
} else {
// bool is_wide = (n1 && n2 && n1 < 0xff && (!n2 || n2 < 0xff));
bool is_wide = needle + rc + 4 < to && !w[0] && w[1] && !w[2] && w[3] && !w[4];
str_type = is_wide? R_STRING_TYPE_WIDE: R_STRING_TYPE_ASCII;
}
} else {
if (rc > 1) {
str_type = R_STRING_TYPE_UTF8; // could be charset if set :?
} else {
str_type = R_STRING_TYPE_ASCII;
}
}
} else if (type == R_STRING_TYPE_UTF8) {
str_type = R_STRING_TYPE_ASCII; // initial assumption
} else {
str_type = type;
}
runes = 0;
str_start = needle;
/* Eat a whole C string */
for (i = 0; i < sizeof (tmp) - 4 && needle < to; i += rc) {
RRune r = {0};
if (str_type == R_STRING_TYPE_WIDE32) {
rc = r_utf32le_decode (buf + needle - from, to - needle, &r);
if (rc) {
rc = 4;
}
} else if (str_type == R_STRING_TYPE_WIDE) {
rc = r_utf16le_decode (buf + needle - from, to - needle, &r);
if (rc == 1) {
rc = 2;
}
} else {
rc = r_utf8_decode (buf + (needle - from), to - needle, &r);
if (rc > 1) {
str_type = R_STRING_TYPE_UTF8;
}
}
/* Invalid sequence detected */
if (!rc || (ascii_only && r > 0x7f)) {
needle++;
break;
}
needle += rc;
if (r_isprint (r) && r != '\\') {
if (str_type == R_STRING_TYPE_WIDE32) {
if (r == 0xff) {
r = 0;
}
}
rc = r_utf8_encode (tmp + i, r);
runes++;
/* Print the escape code */
} else if (r && r < 0x100 && strchr ("\b\v\f\n\r\t\a\033\\", (char)r)) {
if ((i + 32) < sizeof (tmp) && r < 93) {
tmp[i + 0] = '\\';
tmp[i + 1] = " abtnvfr e "
" "
" "
" \\"[r];
} else {
// string too long
break;
}
rc = 2;
runes++;
} else {
/* \0 marks the end of C-strings */
break;
}
}
tmp[i++] = '\0';
if (runes < min && runes >= 2 && str_type == R_STRING_TYPE_ASCII && needle < to) {
// back up past the \0 to the last char just in case it starts a wide string
needle -= 2;
}
if (runes >= min) {
// reduce false positives
int j, num_blocks, *block_list;
int *freq_list = NULL, expected_ascii, actual_ascii, num_chars;
if (str_type == R_STRING_TYPE_ASCII) {
for (j = 0; j < i; j++) {
char ch = tmp[j];
if (ch != '\n' && ch != '\r' && ch != '\t') {
if (!IS_PRINTABLE (tmp[j])) {
continue;
}
}
}
}
switch (str_type) {
case R_STRING_TYPE_UTF8:
case R_STRING_TYPE_WIDE:
case R_STRING_TYPE_WIDE32:
num_blocks = 0;
block_list = r_utf_block_list ((const ut8*)tmp, i - 1,
str_type == R_STRING_TYPE_WIDE? &freq_list: NULL);
if (block_list) {
for (j = 0; block_list[j] != -1; j++) {
num_blocks++;
}
}
if (freq_list) {
num_chars = 0;
actual_ascii = 0;
for (j = 0; freq_list[j] != -1; j++) {
num_chars += freq_list[j];
if (!block_list[j]) { // ASCII
actual_ascii = freq_list[j];
}
}
free (freq_list);
expected_ascii = num_blocks ? num_chars / num_blocks : 0;
if (actual_ascii > expected_ascii) {
ascii_only = true;
needle = str_start;
free (block_list);
continue;
}
}
free (block_list);
if (num_blocks > R_STRING_MAX_UNI_BLOCKS) {
needle++;
continue;
}
}
RBinString *bs = R_NEW0 (RBinString);
if (!bs) {
break;
}
bs->type = str_type;
bs->length = runes;
bs->size = needle - str_start;
bs->ordinal = count++;
// TODO: move into adjust_offset
switch (str_type) {
case R_STRING_TYPE_WIDE:
if (str_start - from > 1) {
const ut8 *p = buf + str_start - 2 - from;
if (p[0] == 0xff && p[1] == 0xfe) {
str_start -= 2; // \xff\xfe
}
}
break;
case R_STRING_TYPE_WIDE32:
if (str_start - from > 3) {
const ut8 *p = buf + str_start - 4 - from;
if (p[0] == 0xff && p[1] == 0xfe) {
str_start -= 4; // \xff\xfe\x00\x00
}
}
break;
}
if (!s) {
if (section) {
s = section;
} else if (bf->o) {
s = r_bin_get_section_at (bf->o, str_start, false);
}
if (s) {
vdelta = s->vaddr;
pdelta = s->paddr;
}
}
ut64 baddr = bf->loadaddr && bf->o? bf->o->baddr: bf->loadaddr;
bs->paddr = str_start + baddr;
bs->vaddr = str_start - pdelta + vdelta + baddr;
bs->string = r_str_ndup ((const char *)tmp, i);
if (list) {
r_list_append (list, bs);
if (bf->o) {
ht_up_insert (bf->o->strings_db, bs->vaddr, bs);
}
} else {
print_string (bf, bs, raw, pj);
r_bin_string_free (bs);
}
if (from == 0 && to == bf->size) {
/* force lookup section at the next one */
s = NULL;
}
}
ascii_only = false;
}
free (buf);
if (pj) {
pj_end (pj);
if (bin) {
RIO *io = bin->iob.io;
if (io) {
io->cb_printf ("%s", pj_string (pj));
}
}
pj_free (pj);
}
return count;
}
| 0
|
474,073
|
cp949_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end,
UChar* lower, OnigEncoding enc)
{
return onigenc_mbn_mbc_case_fold(enc, flag,
pp, end, lower);
}
| 0
|
220,901
|
bool RemoveControlInput(NodeDef* node, const string& control_input_to_remove,
NodeMap* node_map) {
for (int pos = node->input_size() - 1; pos >= 0; --pos) {
const string& input = node->input(pos);
if (input[0] != '^') break;
if (input == control_input_to_remove) {
node->mutable_input()->SwapElements(pos, node->input_size() - 1);
node->mutable_input()->RemoveLast();
node_map->RemoveOutput(NodeName(input), node->name());
return true;
}
}
return false;
}
| 0
|
369,275
|
static ssize_t io_iov_buffer_select(struct io_kiocb *req, struct iovec *iov,
unsigned int issue_flags)
{
if (req->flags & REQ_F_BUFFER_SELECTED) {
struct io_buffer *kbuf = req->kbuf;
iov[0].iov_base = u64_to_user_ptr(kbuf->addr);
iov[0].iov_len = kbuf->len;
return 0;
}
if (req->rw.len != 1)
return -EINVAL;
#ifdef CONFIG_COMPAT
if (req->ctx->compat)
return io_compat_import(req, iov, issue_flags);
#endif
return __io_iov_buffer_select(req, iov, issue_flags);
}
| 0
|
487,674
|
static int notifier_chain_unregister(struct notifier_block **nl,
struct notifier_block *n)
{
while ((*nl) != NULL) {
if ((*nl) == n) {
rcu_assign_pointer(*nl, n->next);
return 0;
}
nl = &((*nl)->next);
}
return -ENOENT;
}
| 0
|
430,469
|
gopherSendComplete(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag errflag, int xerrno, void *data)
{
GopherStateData *gopherState = (GopherStateData *) data;
StoreEntry *entry = gopherState->entry;
debugs(10, 5, HERE << conn << " size: " << size << " errflag: " << errflag);
if (size > 0) {
fd_bytes(conn->fd, size, FD_WRITE);
statCounter.server.all.kbytes_out += size;
statCounter.server.other.kbytes_out += size;
}
if (!entry->isAccepting()) {
debugs(10, 3, "terminating due to bad " << *entry);
// TODO: Do not abuse connection for triggering cleanup.
gopherState->serverConn->close();
return;
}
if (errflag) {
ErrorState *err;
err = new ErrorState(ERR_WRITE_ERROR, Http::scServiceUnavailable, gopherState->fwd->request);
err->xerrno = xerrno;
err->port = gopherState->fwd->request->url.port();
err->url = xstrdup(entry->url());
gopherState->fwd->fail(err);
gopherState->serverConn->close();
return;
}
/*
* OK. We successfully reach remote site. Start MIME typing
* stuff. Do it anyway even though request is not HTML type.
*/
entry->buffer();
gopherMimeCreate(gopherState);
switch (gopherState->type_id) {
case GOPHER_DIRECTORY:
/* we got to convert it first */
gopherState->conversion = GopherStateData::HTML_DIR;
gopherState->HTML_header_added = 0;
break;
case GOPHER_INDEX:
/* we got to convert it first */
gopherState->conversion = GopherStateData::HTML_INDEX_RESULT;
gopherState->HTML_header_added = 0;
break;
case GOPHER_CSO:
/* we got to convert it first */
gopherState->conversion = GopherStateData::HTML_CSO_RESULT;
gopherState->cso_recno = 0;
gopherState->HTML_header_added = 0;
break;
default:
gopherState->conversion = GopherStateData::NORMAL;
entry->flush();
}
/* Schedule read reply. */
AsyncCall::Pointer call = commCbCall(5,5, "gopherReadReply",
CommIoCbPtrFun(gopherReadReply, gopherState));
entry->delayAwareRead(conn, gopherState->replybuf, BUFSIZ, call);
}
| 0
|
211,785
|
static jpc_enc_cp_t *cp_create(const char *optstr, jas_image_t *image)
{
jpc_enc_cp_t *cp;
jas_tvparser_t *tvp;
int ret;
int numilyrrates;
double *ilyrrates;
int i;
int tagid;
jpc_enc_tcp_t *tcp;
jpc_enc_tccp_t *tccp;
jpc_enc_ccp_t *ccp;
uint_fast16_t rlvlno;
uint_fast16_t prcwidthexpn;
uint_fast16_t prcheightexpn;
bool enablemct;
uint_fast32_t jp2overhead;
uint_fast16_t lyrno;
uint_fast32_t hsteplcm;
uint_fast32_t vsteplcm;
bool mctvalid;
tvp = 0;
cp = 0;
ilyrrates = 0;
numilyrrates = 0;
if (!(cp = jas_malloc(sizeof(jpc_enc_cp_t)))) {
goto error;
}
prcwidthexpn = 15;
prcheightexpn = 15;
enablemct = true;
jp2overhead = 0;
cp->ccps = 0;
cp->debug = 0;
cp->imgareatlx = UINT_FAST32_MAX;
cp->imgareatly = UINT_FAST32_MAX;
cp->refgrdwidth = 0;
cp->refgrdheight = 0;
cp->tilegrdoffx = UINT_FAST32_MAX;
cp->tilegrdoffy = UINT_FAST32_MAX;
cp->tilewidth = 0;
cp->tileheight = 0;
cp->numcmpts = jas_image_numcmpts(image);
hsteplcm = 1;
vsteplcm = 1;
for (unsigned cmptno = 0; cmptno < jas_image_numcmpts(image); ++cmptno) {
if (jas_image_cmptbrx(image, cmptno) + jas_image_cmpthstep(image, cmptno) <=
jas_image_brx(image) || jas_image_cmptbry(image, cmptno) +
jas_image_cmptvstep(image, cmptno) <= jas_image_bry(image)) {
jas_eprintf("unsupported image type\n");
goto error;
}
/* Note: We ought to be calculating the LCMs here. Fix some day. */
hsteplcm *= jas_image_cmpthstep(image, cmptno);
vsteplcm *= jas_image_cmptvstep(image, cmptno);
}
if (!(cp->ccps = jas_alloc2(cp->numcmpts, sizeof(jpc_enc_ccp_t)))) {
goto error;
}
unsigned cmptno;
for (cmptno = 0, ccp = cp->ccps; cmptno < cp->numcmpts; ++cmptno,
++ccp) {
ccp->sampgrdstepx = jas_image_cmpthstep(image, cmptno);
ccp->sampgrdstepy = jas_image_cmptvstep(image, cmptno);
/* XXX - this isn't quite correct for more general image */
ccp->sampgrdsubstepx = 0;
ccp->sampgrdsubstepx = 0;
ccp->prec = jas_image_cmptprec(image, cmptno);
ccp->sgnd = jas_image_cmptsgnd(image, cmptno);
ccp->numstepsizes = 0;
memset(ccp->stepsizes, 0, sizeof(ccp->stepsizes));
}
cp->rawsize = jas_image_rawsize(image);
if (cp->rawsize == 0) {
/* prevent division by zero in cp_create() */
goto error;
}
cp->totalsize = UINT_FAST32_MAX;
tcp = &cp->tcp;
tcp->csty = 0;
tcp->intmode = true;
tcp->prg = JPC_COD_LRCPPRG;
tcp->numlyrs = 1;
tcp->ilyrrates = 0;
tccp = &cp->tccp;
tccp->csty = 0;
tccp->maxrlvls = 6;
tccp->cblkwidthexpn = 6;
tccp->cblkheightexpn = 6;
tccp->cblksty = 0;
tccp->numgbits = 2;
if (!(tvp = jas_tvparser_create(optstr ? optstr : ""))) {
goto error;
}
while (!(ret = jas_tvparser_next(tvp))) {
switch (jas_taginfo_nonull(jas_taginfos_lookup(encopts,
jas_tvparser_gettag(tvp)))->id) {
case OPT_DEBUG:
cp->debug = atoi(jas_tvparser_getval(tvp));
break;
case OPT_IMGAREAOFFX:
cp->imgareatlx = atoi(jas_tvparser_getval(tvp));
break;
case OPT_IMGAREAOFFY:
cp->imgareatly = atoi(jas_tvparser_getval(tvp));
break;
case OPT_TILEGRDOFFX:
cp->tilegrdoffx = atoi(jas_tvparser_getval(tvp));
break;
case OPT_TILEGRDOFFY:
cp->tilegrdoffy = atoi(jas_tvparser_getval(tvp));
break;
case OPT_TILEWIDTH:
cp->tilewidth = atoi(jas_tvparser_getval(tvp));
break;
case OPT_TILEHEIGHT:
cp->tileheight = atoi(jas_tvparser_getval(tvp));
break;
case OPT_PRCWIDTH:
prcwidthexpn = jpc_floorlog2(atoi(jas_tvparser_getval(tvp)));
break;
case OPT_PRCHEIGHT:
prcheightexpn = jpc_floorlog2(atoi(jas_tvparser_getval(tvp)));
break;
case OPT_CBLKWIDTH:
tccp->cblkwidthexpn =
jpc_floorlog2(atoi(jas_tvparser_getval(tvp)));
break;
case OPT_CBLKHEIGHT:
tccp->cblkheightexpn =
jpc_floorlog2(atoi(jas_tvparser_getval(tvp)));
break;
case OPT_MODE:
if ((tagid = jas_taginfo_nonull(jas_taginfos_lookup(modetab,
jas_tvparser_getval(tvp)))->id) < 0) {
jas_eprintf("ignoring invalid mode %s\n",
jas_tvparser_getval(tvp));
} else {
tcp->intmode = (tagid == MODE_INT);
}
break;
case OPT_PRG:
if ((tagid = jas_taginfo_nonull(jas_taginfos_lookup(prgordtab,
jas_tvparser_getval(tvp)))->id) < 0) {
jas_eprintf("ignoring invalid progression order %s\n",
jas_tvparser_getval(tvp));
} else {
tcp->prg = tagid;
}
break;
case OPT_NOMCT:
enablemct = false;
break;
case OPT_MAXRLVLS:
tccp->maxrlvls = atoi(jas_tvparser_getval(tvp));
break;
case OPT_SOP:
cp->tcp.csty |= JPC_COD_SOP;
break;
case OPT_EPH:
cp->tcp.csty |= JPC_COD_EPH;
break;
case OPT_LAZY:
tccp->cblksty |= JPC_COX_LAZY;
break;
case OPT_TERMALL:
tccp->cblksty |= JPC_COX_TERMALL;
break;
case OPT_SEGSYM:
tccp->cblksty |= JPC_COX_SEGSYM;
break;
case OPT_VCAUSAL:
tccp->cblksty |= JPC_COX_VSC;
break;
case OPT_RESET:
tccp->cblksty |= JPC_COX_RESET;
break;
case OPT_PTERM:
tccp->cblksty |= JPC_COX_PTERM;
break;
case OPT_NUMGBITS:
cp->tccp.numgbits = atoi(jas_tvparser_getval(tvp));
break;
case OPT_RATE:
if (ratestrtosize(jas_tvparser_getval(tvp), cp->rawsize,
&cp->totalsize)) {
jas_eprintf("ignoring bad rate specifier %s\n",
jas_tvparser_getval(tvp));
}
break;
case OPT_ILYRRATES:
if (jpc_atoaf(jas_tvparser_getval(tvp), &numilyrrates,
&ilyrrates)) {
jas_eprintf("warning: invalid intermediate layer rates specifier ignored (%s)\n",
jas_tvparser_getval(tvp));
}
break;
case OPT_JP2OVERHEAD:
jp2overhead = atoi(jas_tvparser_getval(tvp));
break;
default:
jas_eprintf("warning: ignoring invalid option %s\n",
jas_tvparser_gettag(tvp));
break;
}
}
jas_tvparser_destroy(tvp);
tvp = 0;
if (cp->totalsize != UINT_FAST32_MAX) {
cp->totalsize = (cp->totalsize > jp2overhead) ?
(cp->totalsize - jp2overhead) : 0;
}
if (cp->imgareatlx == UINT_FAST32_MAX) {
cp->imgareatlx = 0;
} else {
if (hsteplcm != 1) {
jas_eprintf("warning: overriding imgareatlx value\n");
}
cp->imgareatlx *= hsteplcm;
}
if (cp->imgareatly == UINT_FAST32_MAX) {
cp->imgareatly = 0;
} else {
if (vsteplcm != 1) {
jas_eprintf("warning: overriding imgareatly value\n");
}
cp->imgareatly *= vsteplcm;
}
cp->refgrdwidth = cp->imgareatlx + jas_image_width(image);
cp->refgrdheight = cp->imgareatly + jas_image_height(image);
if (cp->tilegrdoffx == UINT_FAST32_MAX) {
cp->tilegrdoffx = cp->imgareatlx;
}
if (cp->tilegrdoffy == UINT_FAST32_MAX) {
cp->tilegrdoffy = cp->imgareatly;
}
if (!cp->tilewidth) {
cp->tilewidth = cp->refgrdwidth - cp->tilegrdoffx;
}
if (!cp->tileheight) {
cp->tileheight = cp->refgrdheight - cp->tilegrdoffy;
}
if (cp->numcmpts == 3) {
mctvalid = true;
for (cmptno = 0; cmptno < jas_image_numcmpts(image); ++cmptno) {
if (jas_image_cmptprec(image, cmptno) != jas_image_cmptprec(image, 0) ||
jas_image_cmptsgnd(image, cmptno) != jas_image_cmptsgnd(image, 0) ||
jas_image_cmptwidth(image, cmptno) != jas_image_cmptwidth(image, 0) ||
jas_image_cmptheight(image, cmptno) != jas_image_cmptheight(image, 0)) {
mctvalid = false;
}
}
} else {
mctvalid = false;
}
if (mctvalid && enablemct && jas_clrspc_fam(jas_image_clrspc(image)) != JAS_CLRSPC_FAM_RGB) {
jas_eprintf("warning: color space apparently not RGB\n");
}
if (mctvalid && enablemct && jas_clrspc_fam(jas_image_clrspc(image)) == JAS_CLRSPC_FAM_RGB) {
tcp->mctid = (tcp->intmode) ? (JPC_MCT_RCT) : (JPC_MCT_ICT);
} else {
tcp->mctid = JPC_MCT_NONE;
}
tccp->qmfbid = (tcp->intmode) ? (JPC_COX_RFT) : (JPC_COX_INS);
for (rlvlno = 0; rlvlno < tccp->maxrlvls; ++rlvlno) {
tccp->prcwidthexpns[rlvlno] = prcwidthexpn;
tccp->prcheightexpns[rlvlno] = prcheightexpn;
}
if (prcwidthexpn != 15 || prcheightexpn != 15) {
tccp->csty |= JPC_COX_PRT;
}
/* Ensure that the tile width and height is valid. */
if (!cp->tilewidth) {
jas_eprintf("invalid tile width %lu\n", (unsigned long)
cp->tilewidth);
goto error;
}
if (!cp->tileheight) {
jas_eprintf("invalid tile height %lu\n", (unsigned long)
cp->tileheight);
goto error;
}
/* Ensure that the tile grid offset is valid. */
if (cp->tilegrdoffx > cp->imgareatlx ||
cp->tilegrdoffy > cp->imgareatly ||
cp->tilegrdoffx + cp->tilewidth < cp->imgareatlx ||
cp->tilegrdoffy + cp->tileheight < cp->imgareatly) {
jas_eprintf("invalid tile grid offset (%lu, %lu)\n",
(unsigned long) cp->tilegrdoffx, (unsigned long)
cp->tilegrdoffy);
goto error;
}
cp->numhtiles = JPC_CEILDIV(cp->refgrdwidth - cp->tilegrdoffx,
cp->tilewidth);
cp->numvtiles = JPC_CEILDIV(cp->refgrdheight - cp->tilegrdoffy,
cp->tileheight);
cp->numtiles = cp->numhtiles * cp->numvtiles;
if (ilyrrates && numilyrrates > 0) {
tcp->numlyrs = numilyrrates + 1;
if (!(tcp->ilyrrates = jas_alloc2((tcp->numlyrs - 1),
sizeof(jpc_fix_t)))) {
goto error;
}
for (i = 0; i < JAS_CAST(int, tcp->numlyrs - 1); ++i) {
tcp->ilyrrates[i] = jpc_dbltofix(ilyrrates[i]);
}
}
/* Ensure that the integer mode is used in the case of lossless
coding. */
if (cp->totalsize == UINT_FAST32_MAX && (!cp->tcp.intmode)) {
jas_eprintf("cannot use real mode for lossless coding\n");
goto error;
}
/* Ensure that the precinct width is valid. */
if (prcwidthexpn > 15) {
jas_eprintf("invalid precinct width\n");
goto error;
}
/* Ensure that the precinct height is valid. */
if (prcheightexpn > 15) {
jas_eprintf("invalid precinct height\n");
goto error;
}
/* Ensure that the code block width is valid. */
if (cp->tccp.cblkwidthexpn < 2 || cp->tccp.cblkwidthexpn > 12) {
jas_eprintf("invalid code block width %d\n",
JPC_POW2(cp->tccp.cblkwidthexpn));
goto error;
}
/* Ensure that the code block height is valid. */
if (cp->tccp.cblkheightexpn < 2 || cp->tccp.cblkheightexpn > 12) {
jas_eprintf("invalid code block height %d\n",
JPC_POW2(cp->tccp.cblkheightexpn));
goto error;
}
/* Ensure that the code block size is not too large. */
if (cp->tccp.cblkwidthexpn + cp->tccp.cblkheightexpn > 12) {
jas_eprintf("code block size too large\n");
goto error;
}
/* Ensure that the number of layers is valid. */
if (cp->tcp.numlyrs > 16384) {
jas_eprintf("too many layers\n");
goto error;
}
/* There must be at least one resolution level. */
if (cp->tccp.maxrlvls < 1) {
jas_eprintf("must be at least one resolution level\n");
goto error;
}
/* Ensure that the number of guard bits is valid. */
if (cp->tccp.numgbits > 8) {
jas_eprintf("invalid number of guard bits\n");
goto error;
}
/* Ensure that the rate is within the legal range. */
if (cp->totalsize != UINT_FAST32_MAX && cp->totalsize > cp->rawsize) {
jas_eprintf("warning: specified rate is unreasonably large (%lu > %lu)\n", (unsigned long) cp->totalsize, (unsigned long) cp->rawsize);
}
/* Ensure that the intermediate layer rates are valid. */
if (tcp->numlyrs > 1) {
/* The intermediate layers rates must increase monotonically. */
for (lyrno = 0; lyrno + 2 < tcp->numlyrs; ++lyrno) {
if (tcp->ilyrrates[lyrno] >= tcp->ilyrrates[lyrno + 1]) {
jas_eprintf("intermediate layer rates must increase monotonically\n");
goto error;
}
}
/* The intermediate layer rates must be less than the overall rate. */
if (cp->totalsize != UINT_FAST32_MAX) {
for (lyrno = 0; lyrno < tcp->numlyrs - 1; ++lyrno) {
if (jpc_fixtodbl(tcp->ilyrrates[lyrno]) > ((double) cp->totalsize)
/ cp->rawsize) {
jas_eprintf("warning: intermediate layer rates must be less than overall rate\n");
goto error;
}
}
}
}
if (ilyrrates) {
jas_free(ilyrrates);
}
return cp;
error:
if (ilyrrates) {
jas_free(ilyrrates);
}
if (tvp) {
jas_tvparser_destroy(tvp);
}
if (cp) {
jpc_enc_cp_destroy(cp);
}
return 0;
}
| 1
|
261,198
|
int wm_SemFree(wm_Sem *s){
if ((s == NULL) ||
(*s == NULL))
return MQTT_CODE_ERROR_BAD_ARG;
dispatch_release(*s);
*s = NULL;
return 0;
}
| 0
|
466,136
|
static int em_cmpxchg8b(struct x86_emulate_ctxt *ctxt)
{
u64 old = ctxt->dst.orig_val64;
if (((u32) (old >> 0) != (u32) ctxt->regs[VCPU_REGS_RAX]) ||
((u32) (old >> 32) != (u32) ctxt->regs[VCPU_REGS_RDX])) {
ctxt->regs[VCPU_REGS_RAX] = (u32) (old >> 0);
ctxt->regs[VCPU_REGS_RDX] = (u32) (old >> 32);
ctxt->eflags &= ~EFLG_ZF;
} else {
ctxt->dst.val64 = ((u64)ctxt->regs[VCPU_REGS_RCX] << 32) |
(u32) ctxt->regs[VCPU_REGS_RBX];
ctxt->eflags |= EFLG_ZF;
}
return X86EMUL_CONTINUE;
}
| 0
|
223,461
|
static SLJIT_INLINE PCRE2_SPTR set_then_offsets(compiler_common *common, PCRE2_SPTR cc, sljit_u8 *current_offset)
{
PCRE2_SPTR end = bracketend(cc);
BOOL has_alternatives = cc[GET(cc, 1)] == OP_ALT;
/* Assert captures then. */
if (*cc >= OP_ASSERT && *cc <= OP_ASSERTBACK_NA)
current_offset = NULL;
/* Conditional block does not. */
if (*cc == OP_COND || *cc == OP_SCOND)
has_alternatives = FALSE;
cc = next_opcode(common, cc);
if (has_alternatives)
current_offset = common->then_offsets + (cc - common->start);
while (cc < end)
{
if ((*cc >= OP_ASSERT && *cc <= OP_ASSERTBACK_NA) || (*cc >= OP_ONCE && *cc <= OP_SCOND))
cc = set_then_offsets(common, cc, current_offset);
else
{
if (*cc == OP_ALT && has_alternatives)
current_offset = common->then_offsets + (cc + 1 + LINK_SIZE - common->start);
if (*cc >= OP_THEN && *cc <= OP_THEN_ARG && current_offset != NULL)
*current_offset = 1;
cc = next_opcode(common, cc);
}
}
return end;
}
| 0
|
309,848
|
PutCharLR(NCURSES_SP_DCLx const ARG_CH_T ch)
{
if (!auto_right_margin) {
/* we can put the char directly */
PutAttrChar(NCURSES_SP_ARGx ch);
} else if (enter_am_mode && exit_am_mode) {
/* we can suppress automargin */
NCURSES_PUTP2("exit_am_mode", exit_am_mode);
PutAttrChar(NCURSES_SP_ARGx ch);
SP_PARM->_curscol--;
position_check(NCURSES_SP_ARGx
SP_PARM->_cursrow,
SP_PARM->_curscol,
"exit_am_mode");
NCURSES_PUTP2("enter_am_mode", enter_am_mode);
} else if ((enter_insert_mode && exit_insert_mode)
|| insert_character || parm_ich) {
GoTo(NCURSES_SP_ARGx
screen_lines(SP_PARM) - 1,
screen_columns(SP_PARM) - 2);
PutAttrChar(NCURSES_SP_ARGx ch);
GoTo(NCURSES_SP_ARGx
screen_lines(SP_PARM) - 1,
screen_columns(SP_PARM) - 2);
InsStr(NCURSES_SP_ARGx
NewScreen(SP_PARM)->_line[screen_lines(SP_PARM) - 1].text +
screen_columns(SP_PARM) - 2, 1);
}
}
| 0
|
318,959
|
prepare_assert_error(garray_T *gap)
{
char buf[NUMBUFLEN];
char_u *sname = estack_sfile(ESTACK_NONE);
ga_init2(gap, 1, 100);
if (sname != NULL)
{
ga_concat(gap, sname);
if (SOURCING_LNUM > 0)
ga_concat(gap, (char_u *)" ");
}
if (SOURCING_LNUM > 0)
{
sprintf(buf, "line %ld", (long)SOURCING_LNUM);
ga_concat(gap, (char_u *)buf);
}
if (sname != NULL || SOURCING_LNUM > 0)
ga_concat(gap, (char_u *)": ");
vim_free(sname);
}
| 0
|
384,300
|
heap_available()
{
long avail = 0;
void *probes[max_malloc_probes];
uint n;
for (n = 0; n < max_malloc_probes; n++) {
if ((probes[n] = malloc(malloc_probe_size)) == 0)
break;
if_debug2('a', "[a]heap_available probe[%d]=0x%lx\n",
n, (ulong) probes[n]);
avail += malloc_probe_size;
}
while (n)
free(probes[--n]);
return avail;
}
| 0
|
220,463
|
Status BuildXlaCompilationCache(DeviceBase* device, FunctionLibraryRuntime* flr,
const XlaPlatformInfo& platform_info,
XlaCompilationCache** cache) {
if (platform_info.xla_device_metadata()) {
*cache = new XlaCompilationCache(
platform_info.xla_device_metadata()->client(),
platform_info.xla_device_metadata()->jit_device_type());
return Status::OK();
}
auto platform =
se::MultiPlatformManager::PlatformWithId(platform_info.platform_id());
if (!platform.ok()) {
return platform.status();
}
StatusOr<xla::Compiler*> compiler_for_platform =
xla::Compiler::GetForPlatform(platform.ValueOrDie());
if (!compiler_for_platform.ok()) {
// In some rare cases (usually in unit tests with very small clusters) we
// may end up transforming an XLA cluster with at least one GPU operation
// (which would normally force the cluster to be compiled using XLA:GPU)
// into an XLA cluster with no GPU operations (i.e. containing only CPU
// operations). Such a cluster can fail compilation (in way that
// MarkForCompilation could not have detected) if the CPU JIT is not linked
// in.
//
// So bail out of _XlaCompile in this case, and let the executor handle the
// situation for us.
const Status& status = compiler_for_platform.status();
if (status.code() == error::NOT_FOUND) {
return errors::Unimplemented("Could not find compiler for platform ",
platform.ValueOrDie()->Name(), ": ",
status.ToString());
}
}
xla::LocalClientOptions client_options;
client_options.set_platform(platform.ValueOrDie());
client_options.set_intra_op_parallelism_threads(
device->tensorflow_cpu_worker_threads()->num_threads);
if (flr->config_proto()) {
string allowed_gpus =
flr->config_proto()->gpu_options().visible_device_list();
TF_ASSIGN_OR_RETURN(absl::optional<std::set<int>> gpu_ids,
ParseVisibleDeviceList(allowed_gpus));
client_options.set_allowed_devices(gpu_ids);
}
auto client = xla::ClientLibrary::GetOrCreateLocalClient(client_options);
if (!client.ok()) {
return client.status();
}
const XlaOpRegistry::DeviceRegistration* registration;
if (!XlaOpRegistry::GetCompilationDevice(platform_info.device_type().type(),
®istration)) {
return errors::InvalidArgument("No JIT device registered for ",
platform_info.device_type().type());
}
*cache = new XlaCompilationCache(
client.ValueOrDie(), DeviceType(registration->compilation_device_name));
return Status::OK();
}
| 0
|
270,358
|
parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
{
parser_loop_statement_t loop;
JERRY_ASSERT (context_p->token.type == LEXER_KEYW_FOR);
lexer_next_token (context_p);
#if JERRY_ESNEXT
bool is_for_await = false;
if (context_p->token.type == LEXER_KEYW_AWAIT)
{
if (JERRY_UNLIKELY (context_p->token.lit_location.status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE))
{
parser_raise_error (context_p, PARSER_ERR_INVALID_KEYWORD);
}
lexer_next_token (context_p);
is_for_await = true;
}
#endif /* JERRY_ESNEXT */
if (context_p->token.type != LEXER_LEFT_PAREN)
{
#if JERRY_ESNEXT
if (context_p->token.type == LEXER_LITERAL
&& context_p->token.keyword_type == LEXER_KEYW_AWAIT
&& !(context_p->token.lit_location.status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE))
{
parser_raise_error (context_p, PARSER_ERR_FOR_AWAIT_NO_ASYNC);
}
#endif /* JERRY_ESNEXT */
parser_raise_error (context_p, PARSER_ERR_LEFT_PAREN_EXPECTED);
}
if (context_p->next_scanner_info_p->source_p == context_p->source_p)
{
parser_for_in_of_statement_t for_in_of_statement;
scanner_location_t start_location, end_location;
#if JERRY_ESNEXT
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_IN
|| context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_OF);
bool is_for_in = (context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_IN);
end_location = ((scanner_location_info_t *) context_p->next_scanner_info_p)->location;
scanner_release_next (context_p, sizeof (scanner_location_info_t));
scanner_get_location (&start_location, context_p);
lexer_next_token (context_p);
uint8_t token_type = LEXER_EOS;
bool has_context = false;
if (context_p->token.type == LEXER_KEYW_VAR
|| context_p->token.type == LEXER_KEYW_LET
|| context_p->token.type == LEXER_KEYW_CONST)
{
token_type = context_p->token.type;
has_context = context_p->next_scanner_info_p->source_p == context_p->source_p;
JERRY_ASSERT (!has_context || context_p->next_scanner_info_p->type == SCANNER_TYPE_BLOCK);
scanner_get_location (&start_location, context_p);
/* TODO: remove this after the pre-scanner supports strict mode detection. */
if (context_p->next_scanner_info_p->source_p == context_p->source_p
&& context_p->next_scanner_info_p->type == SCANNER_TYPE_LET_EXPRESSION)
{
scanner_release_next (context_p, sizeof (scanner_info_t));
}
}
else if (context_p->token.type == LEXER_LITERAL && lexer_token_is_let (context_p))
{
if (context_p->next_scanner_info_p->source_p == context_p->source_p
&& context_p->next_scanner_info_p->type == SCANNER_TYPE_LET_EXPRESSION)
{
scanner_release_next (context_p, sizeof (scanner_info_t));
}
else
{
token_type = LEXER_KEYW_LET;
has_context = (context_p->next_scanner_info_p->source_p == context_p->source_p);
scanner_get_location (&start_location, context_p);
}
}
if (has_context)
{
has_context = parser_push_block_context (context_p, true);
}
scanner_set_location (context_p, &end_location);
#else /* !JERRY_ESNEXT */
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_IN);
bool is_for_in = true;
scanner_get_location (&start_location, context_p);
scanner_set_location (context_p, &((scanner_location_info_t *) context_p->next_scanner_info_p)->location);
scanner_release_next (context_p, sizeof (scanner_location_info_t));
#endif /* JERRY_ESNEXT */
/* The length of both 'in' and 'of' is two. */
const uint8_t *source_end_p = context_p->source_p - 2;
scanner_seek (context_p);
#if JERRY_ESNEXT
if (is_for_in && is_for_await)
{
context_p->token.line = context_p->line;
context_p->token.column = context_p->column - 2;
parser_raise_error (context_p, PARSER_ERR_FOR_AWAIT_NO_OF);
}
#endif /* JERRY_ESNEXT */
lexer_next_token (context_p);
int options = is_for_in ? PARSE_EXPR : PARSE_EXPR_LEFT_HAND_SIDE;
parser_parse_expression (context_p, options);
if (context_p->token.type != LEXER_RIGHT_PAREN)
{
parser_raise_error (context_p, PARSER_ERR_RIGHT_PAREN_EXPECTED);
}
#ifndef JERRY_NDEBUG
PARSER_PLUS_EQUAL_U16 (context_p->context_stack_depth,
is_for_in ? PARSER_FOR_IN_CONTEXT_STACK_ALLOCATION
: PARSER_FOR_OF_CONTEXT_STACK_ALLOCATION);
#endif /* !JERRY_NDEBUG */
cbc_ext_opcode_t init_opcode = CBC_EXT_FOR_IN_INIT;
#if JERRY_ESNEXT
if (!is_for_in)
{
init_opcode = is_for_await ? CBC_EXT_FOR_AWAIT_OF_INIT : CBC_EXT_FOR_OF_INIT;
}
#endif /* JERRY_ESNEXT */
parser_emit_cbc_ext_forward_branch (context_p, init_opcode, &for_in_of_statement.branch);
JERRY_ASSERT (context_p->last_cbc_opcode == PARSER_CBC_UNAVAILABLE);
for_in_of_statement.start_offset = context_p->byte_code_size;
#if JERRY_ESNEXT
if (has_context)
{
parser_emit_cbc_ext (context_p, CBC_EXT_CLONE_CONTEXT);
}
#endif /* JERRY_ESNEXT */
/* The expression parser must not read the 'in' or 'of' tokens. */
scanner_get_location (&end_location, context_p);
scanner_set_location (context_p, &start_location);
const uint8_t *original_source_end_p = context_p->source_end_p;
context_p->source_end_p = source_end_p;
scanner_seek (context_p);
#if JERRY_ESNEXT
if (token_type == LEXER_EOS)
{
lexer_next_token (context_p);
if (context_p->token.type == LEXER_LEFT_SQUARE || context_p->token.type == LEXER_LEFT_BRACE)
{
token_type = context_p->token.type;
}
}
#else /* !JERRY_ESNEXT */
lexer_next_token (context_p);
uint8_t token_type = context_p->token.type;
#endif /* JERRY_ESNEXT */
switch (token_type)
{
#if JERRY_ESNEXT
case LEXER_KEYW_LET:
case LEXER_KEYW_CONST:
#endif /* JERRY_ESNEXT */
case LEXER_KEYW_VAR:
{
#if JERRY_ESNEXT
if (lexer_check_next_characters (context_p, LIT_CHAR_LEFT_SQUARE, LIT_CHAR_LEFT_BRACE))
{
parser_emit_cbc_ext (context_p, is_for_in ? CBC_EXT_FOR_IN_GET_NEXT
: CBC_EXT_FOR_OF_GET_NEXT);
parser_pattern_flags_t flags = (PARSER_PATTERN_BINDING | PARSER_PATTERN_TARGET_ON_STACK);
if (context_p->next_scanner_info_p->source_p == (context_p->source_p + 1))
{
if (context_p->next_scanner_info_p->type == SCANNER_TYPE_INITIALIZER)
{
scanner_release_next (context_p, sizeof (scanner_location_info_t));
}
else
{
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_LITERAL_FLAGS);
if (context_p->next_scanner_info_p->u8_arg & SCANNER_LITERAL_OBJECT_HAS_REST)
{
flags |= PARSER_PATTERN_HAS_REST_ELEMENT;
}
scanner_release_next (context_p, sizeof (scanner_info_t));
}
}
if (token_type == LEXER_KEYW_LET)
{
flags |= PARSER_PATTERN_LET;
}
else if (token_type == LEXER_KEYW_CONST)
{
flags |= PARSER_PATTERN_CONST;
}
parser_parse_initializer_by_next_char (context_p, flags);
break;
}
#endif /* JERRY_ESNEXT */
lexer_expect_identifier (context_p, LEXER_IDENT_LITERAL);
#if JERRY_ESNEXT
if (context_p->token.keyword_type == LEXER_KEYW_LET
&& token_type != LEXER_KEYW_VAR)
{
parser_raise_error (context_p, PARSER_ERR_LEXICAL_LET_BINDING);
}
#endif /* JERRY_ESNEXT */
JERRY_ASSERT (context_p->token.type == LEXER_LITERAL
&& context_p->token.lit_location.type == LEXER_IDENT_LITERAL);
uint16_t literal_index = context_p->lit_object.index;
lexer_next_token (context_p);
if (context_p->token.type == LEXER_ASSIGN)
{
#if JERRY_ESNEXT
if ((context_p->status_flags & PARSER_IS_STRICT) || !is_for_in)
{
parser_raise_error (context_p, PARSER_ERR_FOR_IN_OF_DECLARATION);
}
#endif /* JERRY_ESNEXT */
parser_branch_t branch;
/* Initialiser is never executed. */
parser_emit_cbc_forward_branch (context_p, CBC_JUMP_FORWARD, &branch);
lexer_next_token (context_p);
parser_parse_expression_statement (context_p, PARSE_EXPR_NO_COMMA);
parser_set_branch_to_current_position (context_p, &branch);
}
parser_emit_cbc_ext (context_p, is_for_in ? CBC_EXT_FOR_IN_GET_NEXT
: CBC_EXT_FOR_OF_GET_NEXT);
#if JERRY_ESNEXT
#ifndef JERRY_NDEBUG
if (literal_index < PARSER_REGISTER_START
&& has_context
&& !scanner_literal_is_created (context_p, literal_index))
{
context_p->global_status_flags |= ECMA_PARSE_INTERNAL_FOR_IN_OFF_CONTEXT_ERROR;
}
#endif /* !JERRY_NDEBUG */
uint16_t opcode = (has_context ? CBC_ASSIGN_LET_CONST : CBC_ASSIGN_SET_IDENT);
parser_emit_cbc_literal (context_p, opcode, literal_index);
#else /* !JERRY_ESNEXT */
parser_emit_cbc_literal (context_p, CBC_ASSIGN_SET_IDENT, literal_index);
#endif /* JERRY_ESNEXT */
break;
}
#if JERRY_ESNEXT
case LEXER_LEFT_BRACE:
case LEXER_LEFT_SQUARE:
{
if (context_p->next_scanner_info_p->source_p == context_p->source_p
&& context_p->next_scanner_info_p->type == SCANNER_TYPE_LITERAL_FLAGS
&& (context_p->next_scanner_info_p->u8_arg & SCANNER_LITERAL_DESTRUCTURING_FOR))
{
parser_emit_cbc_ext (context_p, is_for_in ? CBC_EXT_FOR_IN_GET_NEXT
: CBC_EXT_FOR_OF_GET_NEXT);
uint32_t flags = PARSER_PATTERN_TARGET_ON_STACK;
if (context_p->next_scanner_info_p->u8_arg & SCANNER_LITERAL_OBJECT_HAS_REST)
{
flags |= PARSER_PATTERN_HAS_REST_ELEMENT;
}
scanner_release_next (context_p, sizeof (scanner_info_t));
parser_parse_initializer (context_p, flags);
/* Pop the value returned by GET_NEXT. */
parser_emit_cbc (context_p, CBC_POP);
break;
}
/* FALLTHRU */
}
#endif /* JERRY_ESNEXT */
default:
{
uint16_t opcode;
parser_parse_expression (context_p, PARSE_EXPR_LEFT_HAND_SIDE);
opcode = context_p->last_cbc_opcode;
/* The CBC_EXT_FOR_IN_CREATE_CONTEXT flushed the opcode combiner. */
JERRY_ASSERT (opcode != CBC_PUSH_TWO_LITERALS
&& opcode != CBC_PUSH_THREE_LITERALS);
opcode = parser_check_left_hand_side_expression (context_p, opcode);
parser_emit_cbc_ext (context_p, is_for_in ? CBC_EXT_FOR_IN_GET_NEXT
: CBC_EXT_FOR_OF_GET_NEXT);
parser_flush_cbc (context_p);
context_p->last_cbc_opcode = opcode;
break;
}
}
if (context_p->token.type != LEXER_EOS)
{
#if JERRY_ESNEXT
parser_raise_error (context_p, is_for_in ? PARSER_ERR_IN_EXPECTED : PARSER_ERR_OF_EXPECTED);
#else /* !JERRY_ESNEXT */
parser_raise_error (context_p, PARSER_ERR_IN_EXPECTED);
#endif /* JERRY_ESNEXT */
}
parser_flush_cbc (context_p);
scanner_set_location (context_p, &end_location);
context_p->source_end_p = original_source_end_p;
lexer_next_token (context_p);
loop.branch_list_p = NULL;
parser_stack_push (context_p, &for_in_of_statement, sizeof (parser_for_in_of_statement_t));
parser_stack_push (context_p, &loop, sizeof (parser_loop_statement_t));
uint8_t for_type = PARSER_STATEMENT_FOR_IN;
#if JERRY_ESNEXT
if (!is_for_in)
{
for_type = is_for_await ? PARSER_STATEMENT_FOR_AWAIT_OF : PARSER_STATEMENT_FOR_OF;
}
#endif /* JERRY_ESNEXT */
parser_stack_push_uint8 (context_p, for_type);
parser_stack_iterator_init (context_p, &context_p->last_statement);
return;
}
lexer_next_token (context_p);
if (context_p->token.type != LEXER_SEMICOLON)
{
#if JERRY_ESNEXT
const uint8_t *source_p = context_p->source_p;
#endif /* JERRY_ESNEXT */
switch (context_p->token.type)
{
#if JERRY_ESNEXT
case LEXER_LITERAL:
{
if (!lexer_token_is_let (context_p))
{
parser_parse_expression_statement (context_p, PARSE_EXPR);
break;
}
/* FALLTHRU */
}
case LEXER_KEYW_LET:
{
if (context_p->next_scanner_info_p->source_p == context_p->source_p
&& context_p->next_scanner_info_p->type != SCANNER_TYPE_BLOCK)
{
if (context_p->next_scanner_info_p->type == SCANNER_TYPE_LET_EXPRESSION)
{
scanner_release_next (context_p, sizeof (scanner_info_t));
}
parser_parse_expression_statement (context_p, PARSE_EXPR);
break;
}
context_p->token.type = LEXER_KEYW_LET;
/* FALLTHRU */
}
case LEXER_KEYW_CONST:
{
if (context_p->next_scanner_info_p->source_p == source_p)
{
parser_push_block_context (context_p, true);
}
/* FALLTHRU */
}
#endif /* JERRY_ESNEXT */
case LEXER_KEYW_VAR:
{
parser_parse_var_statement (context_p);
break;
}
default:
{
parser_parse_expression_statement (context_p, PARSE_EXPR);
break;
}
}
if (context_p->token.type != LEXER_SEMICOLON)
{
parser_raise_error (context_p, PARSER_ERR_SEMICOLON_EXPECTED);
}
}
#if JERRY_ESNEXT
if (is_for_await)
{
parser_raise_error (context_p, PARSER_ERR_FOR_AWAIT_NO_OF);
}
#endif /* JERRY_ESNEXT */
JERRY_ASSERT (context_p->next_scanner_info_p->source_p != context_p->source_p
|| context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR);
if (context_p->next_scanner_info_p->source_p != context_p->source_p
|| ((scanner_for_info_t *) context_p->next_scanner_info_p)->end_location.source_p == NULL)
{
if (context_p->next_scanner_info_p->source_p == context_p->source_p)
{
/* Even though the scanning is failed, there might be valid statements
* inside the for statement which depend on scanner info blocks. */
scanner_release_next (context_p, sizeof (scanner_for_info_t));
}
/* The prescanner couldn't find the second semicolon or the closing paranthesis. */
lexer_next_token (context_p);
parser_parse_expression (context_p, PARSE_EXPR);
if (context_p->token.type != LEXER_SEMICOLON)
{
parser_raise_error (context_p, PARSER_ERR_SEMICOLON_EXPECTED);
}
lexer_next_token (context_p);
parser_parse_expression_statement (context_p, PARSE_EXPR);
JERRY_ASSERT (context_p->token.type != LEXER_RIGHT_PAREN);
parser_raise_error (context_p, PARSER_ERR_RIGHT_PAREN_EXPECTED);
}
parser_for_statement_t for_statement;
scanner_for_info_t *for_info_p = (scanner_for_info_t *) context_p->next_scanner_info_p;
parser_emit_cbc_forward_branch (context_p, CBC_JUMP_FORWARD, &for_statement.branch);
JERRY_ASSERT (context_p->last_cbc_opcode == PARSER_CBC_UNAVAILABLE);
for_statement.start_offset = context_p->byte_code_size;
scanner_get_location (&for_statement.condition_location, context_p);
for_statement.expression_location = for_info_p->expression_location;
scanner_set_location (context_p, &for_info_p->end_location);
scanner_release_next (context_p, sizeof (scanner_for_info_t));
scanner_seek (context_p);
lexer_next_token (context_p);
loop.branch_list_p = NULL;
parser_stack_push (context_p, &for_statement, sizeof (parser_for_statement_t));
parser_stack_push (context_p, &loop, sizeof (parser_loop_statement_t));
parser_stack_push_uint8 (context_p, PARSER_STATEMENT_FOR);
parser_stack_iterator_init (context_p, &context_p->last_statement);
} /* parser_parse_for_statement_start */
| 0
|
259,196
|
static int mov_try_read_block(AVIOContext *pb, size_t size, uint8_t **data)
{
const unsigned int block_size = 1024 * 1024;
uint8_t *buffer = NULL;
unsigned int alloc_size = 0, offset = 0;
while (offset < size) {
unsigned int new_size =
alloc_size >= INT_MAX - block_size ? INT_MAX : alloc_size + block_size;
uint8_t *new_buffer = av_fast_realloc(buffer, &alloc_size, new_size);
unsigned int to_read = FFMIN(size, alloc_size) - offset;
if (!new_buffer) {
av_free(buffer);
return AVERROR(ENOMEM);
}
buffer = new_buffer;
if (avio_read(pb, buffer + offset, to_read) != to_read) {
av_free(buffer);
return AVERROR_INVALIDDATA;
}
offset += to_read;
}
*data = buffer;
return 0;
}
| 0
|
307,850
|
ciEnv::~ciEnv() {
CompilerThread* current_thread = CompilerThread::current();
_factory->remove_symbols();
// Need safepoint to clear the env on the thread. RedefineClasses might
// be reading it.
GUARDED_VM_ENTRY(current_thread->set_env(NULL);)
}
| 0
|
264,657
|
static GF_Err BM_ParseGlobalQuantizer(GF_BifsDecoder *codec, GF_BitStream *bs, GF_List *com_list)
{
GF_Node *node;
GF_Command *com;
GF_CommandField *inf;
node = gf_bifs_dec_node(codec, bs, NDT_SFWorldNode);
if (!node) return GF_NON_COMPLIANT_BITSTREAM;
/*reset global QP*/
if (codec->scenegraph->global_qp) {
gf_node_unregister(codec->scenegraph->global_qp, NULL);
}
codec->ActiveQP = NULL;
codec->scenegraph->global_qp = NULL;
if (gf_node_get_tag(node) != TAG_MPEG4_QuantizationParameter) {
//if node was just created (num_instances == 0), unregister
//otherwise (USE node) don't do anything
if (!node->sgprivate->num_instances) {
node->sgprivate->num_instances = 1;
gf_node_unregister(node, NULL);
}
return GF_NON_COMPLIANT_BITSTREAM;
}
/*register global QP*/
codec->ActiveQP = (M_QuantizationParameter *) node;
codec->ActiveQP->isLocal = 0;
codec->scenegraph->global_qp = node;
/*register TWICE: once for the command, and for the scenegraph globalQP*/
gf_node_unregister(node, NULL);
gf_node_unregister(node, NULL);
com = gf_sg_command_new(codec->current_graph, GF_SG_GLOBAL_QUANTIZER);
inf = gf_sg_command_field_new(com);
inf->new_node = node;
inf->field_ptr = &inf->new_node;
inf->fieldType = GF_SG_VRML_SFNODE;
gf_list_add(com_list, com);
return GF_OK;
}
| 0
|
336,613
|
static gpointer openssl_global_init_once(gpointer arg)
{
SSL_library_init();
SSL_load_error_strings();
openssl_thread_setup();
return NULL;
}
| 0
|
212,347
|
append_command(char_u *cmd)
{
char_u *s = cmd;
char_u *d;
STRCAT(IObuff, ": ");
d = IObuff + STRLEN(IObuff);
while (*s != NUL && d - IObuff + 5 < IOSIZE)
{
if (enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : *s == 0xa0)
{
s += enc_utf8 ? 2 : 1;
STRCPY(d, "<a0>");
d += 4;
}
else if (d - IObuff + (*mb_ptr2len)(s) + 1 >= IOSIZE)
break;
else
MB_COPY_CHAR(s, d);
}
*d = NUL;
}
| 1
|
443,704
|
utf16be_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
{
const UChar* p = *pp;
(*pp) += EncLen_UTF16[*p];
if (*p == 0) {
int c, v;
p++;
if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
return TRUE;
}
c = *p;
v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c,
(BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
if ((v | BIT_CTYPE_LOWER) != 0) {
/* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */
if (c >= 0xaa && c <= 0xba)
return FALSE;
else
return TRUE;
}
return (v != 0 ? TRUE : FALSE);
}
return FALSE;
}
| 0
|
372,354
|
static char *sdb_find_arg(char *p)
{
p++;
while (*p==' ') p++;
char *pp=p;
while (*pp>' ') pp++;
*pp='\0';
return p;
}
| 0
|
439,141
|
static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
char
colorspace[MaxTextExtent],
text[MaxTextExtent];
double
x_offset,
y_offset;
Image
*image;
IndexPacket
*indexes;
MagickBooleanType
status;
MagickPixelPacket
pixel;
QuantumAny
range;
register ssize_t
i,
x;
register PixelPacket
*q;
ssize_t
count,
type,
y;
unsigned long
depth,
height,
max_value,
width;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
(void) memset(text,0,sizeof(text));
(void) ReadBlobString(image,text);
if (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) != 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
x_offset=(-1.0);
y_offset=(-1.0);
do
{
width=0;
height=0;
max_value=0;
*colorspace='\0';
count=(ssize_t) sscanf(text+32,"%lu,%lu,%lu,%32s",&width,&height,&max_value,
colorspace);
if ((count != 4) || (width == 0) || (height == 0) || (max_value == 0))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
image->columns=width;
image->rows=height;
if ((max_value == 0) || (max_value > 4294967295U))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
for (depth=1; (GetQuantumRange(depth)+1) < max_value; depth++) ;
image->depth=depth;
status=SetImageExtent(image,image->columns,image->rows);
if (status != MagickFalse)
status=ResetImagePixels(image,&image->exception);
if (status == MagickFalse)
{
InheritException(exception,&image->exception);
return(DestroyImageList(image));
}
LocaleLower(colorspace);
i=(ssize_t) strlen(colorspace)-1;
image->matte=MagickFalse;
if ((i > 0) && (colorspace[i] == 'a'))
{
colorspace[i]='\0';
image->matte=MagickTrue;
}
type=ParseCommandOption(MagickColorspaceOptions,MagickFalse,colorspace);
if (type < 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
image->colorspace=(ColorspaceType) type;
(void) memset(&pixel,0,sizeof(pixel));
(void) SetImageBackgroundColor(image);
range=GetQuantumRange(image->depth);
status=MagickTrue;
for (y=0; y < (ssize_t) image->rows; y++)
{
double
blue,
green,
index,
opacity,
red;
if (status == MagickFalse)
break;
red=0.0;
green=0.0;
blue=0.0;
index=0.0;
opacity=0.0;
for (x=0; x < (ssize_t) image->columns; x++)
{
if (ReadBlobString(image,text) == (char *) NULL)
{
status=MagickFalse;
break;
}
switch (image->colorspace)
{
case LinearGRAYColorspace:
case GRAYColorspace:
{
if (image->matte != MagickFalse)
{
(void) sscanf(text,"%lf,%lf: (%lf%*[%,]%lf%*[%,]",&x_offset,
&y_offset,&red,&opacity);
green=red;
blue=red;
break;
}
(void) sscanf(text,"%lf,%lf: (%lf%*[%,]",&x_offset,&y_offset,&red);
green=red;
blue=red;
break;
}
case CMYKColorspace:
{
if (image->matte != MagickFalse)
{
(void) sscanf(text,
"%lf,%lf: (%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]",
&x_offset,&y_offset,&red,&green,&blue,&index,&opacity);
break;
}
(void) sscanf(text,
"%lf,%lf: (%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]",&x_offset,
&y_offset,&red,&green,&blue,&index);
break;
}
default:
{
if (image->matte != MagickFalse)
{
(void) sscanf(text,
"%lf,%lf: (%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]",
&x_offset,&y_offset,&red,&green,&blue,&opacity);
break;
}
(void) sscanf(text,"%lf,%lf: (%lf%*[%,]%lf%*[%,]%lf%*[%,]",
&x_offset,&y_offset,&red,&green,&blue);
break;
}
}
if (strchr(text,'%') != (char *) NULL)
{
red*=0.01*range;
green*=0.01*range;
blue*=0.01*range;
index*=0.01*range;
opacity*=0.01*range;
}
if (image->colorspace == LabColorspace)
{
green+=(range+1)/2.0;
blue+=(range+1)/2.0;
}
pixel.red=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (red+0.5),
range);
pixel.green=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (green+0.5),
range);
pixel.blue=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (blue+0.5),
range);
pixel.index=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (index+0.5),
range);
pixel.opacity=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (opacity+
0.5),range);
q=GetAuthenticPixels(image,(ssize_t) x_offset,(ssize_t) y_offset,1,1,
exception);
if (q == (PixelPacket *) NULL)
continue;
SetPixelRed(q,pixel.red);
SetPixelGreen(q,pixel.green);
SetPixelBlue(q,pixel.blue);
if (image->colorspace == CMYKColorspace)
{
indexes=GetAuthenticIndexQueue(image);
SetPixelIndex(indexes,pixel.index);
}
if (image->matte != MagickFalse)
SetPixelAlpha(q,pixel.opacity);
if (SyncAuthenticPixels(image,exception) == MagickFalse)
{
status=MagickFalse;
break;
}
}
}
if (status == MagickFalse)
break;
*text='\0';
(void) ReadBlobString(image,text);
if (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) == 0)
{
/*
Allocate next image structure.
*/
AcquireNextImage(image_info,image);
if (GetNextImageInList(image) == (Image *) NULL)
{
status=MagickFalse;
break;
}
image=SyncNextImageInList(image);
status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
GetBlobSize(image));
if (status == MagickFalse)
break;
}
} while (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) == 0);
(void) CloseBlob(image);
if (status == MagickFalse)
return(DestroyImageList(image));
return(GetFirstImageInList(image));
}
| 0
|
226,437
|
Status CheckExternalState() const override { return Status::OK(); }
| 0
|
206,677
|
unix_expandpath(
garray_T *gap,
char_u *path,
int wildoff,
int flags, // EW_* flags
int didstar) // expanded "**" once already
{
char_u *buf;
char_u *path_end;
char_u *p, *s, *e;
int start_len = gap->ga_len;
char_u *pat;
regmatch_T regmatch;
int starts_with_dot;
int matches;
int len;
int starstar = FALSE;
static int stardepth = 0; // depth for "**" expansion
DIR *dirp;
struct dirent *dp;
// Expanding "**" may take a long time, check for CTRL-C.
if (stardepth > 0)
{
ui_breakcheck();
if (got_int)
return 0;
}
// make room for file name
buf = alloc(STRLEN(path) + BASENAMELEN + 5);
if (buf == NULL)
return 0;
/*
* Find the first part in the path name that contains a wildcard.
* When EW_ICASE is set every letter is considered to be a wildcard.
* Copy it into "buf", including the preceding characters.
*/
p = buf;
s = buf;
e = NULL;
path_end = path;
while (*path_end != NUL)
{
// May ignore a wildcard that has a backslash before it; it will
// be removed by rem_backslash() or file_pat_to_reg_pat() below.
if (path_end >= path + wildoff && rem_backslash(path_end))
*p++ = *path_end++;
else if (*path_end == '/')
{
if (e != NULL)
break;
s = p + 1;
}
else if (path_end >= path + wildoff
&& (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL
|| (!p_fic && (flags & EW_ICASE)
&& isalpha(PTR2CHAR(path_end)))))
e = p;
if (has_mbyte)
{
len = (*mb_ptr2len)(path_end);
STRNCPY(p, path_end, len);
p += len;
path_end += len;
}
else
*p++ = *path_end++;
}
e = p;
*e = NUL;
// Now we have one wildcard component between "s" and "e".
// Remove backslashes between "wildoff" and the start of the wildcard
// component.
for (p = buf + wildoff; p < s; ++p)
if (rem_backslash(p))
{
STRMOVE(p, p + 1);
--e;
--s;
}
// Check for "**" between "s" and "e".
for (p = s; p < e; ++p)
if (p[0] == '*' && p[1] == '*')
starstar = TRUE;
// convert the file pattern to a regexp pattern
starts_with_dot = *s == '.';
pat = file_pat_to_reg_pat(s, e, NULL, FALSE);
if (pat == NULL)
{
vim_free(buf);
return 0;
}
// compile the regexp into a program
if (flags & EW_ICASE)
regmatch.rm_ic = TRUE; // 'wildignorecase' set
else
regmatch.rm_ic = p_fic; // ignore case when 'fileignorecase' is set
if (flags & (EW_NOERROR | EW_NOTWILD))
++emsg_silent;
regmatch.regprog = vim_regcomp(pat, RE_MAGIC);
if (flags & (EW_NOERROR | EW_NOTWILD))
--emsg_silent;
vim_free(pat);
if (regmatch.regprog == NULL && (flags & EW_NOTWILD) == 0)
{
vim_free(buf);
return 0;
}
// If "**" is by itself, this is the first time we encounter it and more
// is following then find matches without any directory.
if (!didstar && stardepth < 100 && starstar && e - s == 2
&& *path_end == '/')
{
STRCPY(s, path_end + 1);
++stardepth;
(void)unix_expandpath(gap, buf, (int)(s - buf), flags, TRUE);
--stardepth;
}
// open the directory for scanning
*s = NUL;
dirp = opendir(*buf == NUL ? "." : (char *)buf);
// Find all matching entries
if (dirp != NULL)
{
for (;;)
{
dp = readdir(dirp);
if (dp == NULL)
break;
if ((dp->d_name[0] != '.' || starts_with_dot
|| ((flags & EW_DODOT)
&& dp->d_name[1] != NUL
&& (dp->d_name[1] != '.' || dp->d_name[2] != NUL)))
&& ((regmatch.regprog != NULL && vim_regexec(®match,
(char_u *)dp->d_name, (colnr_T)0))
|| ((flags & EW_NOTWILD)
&& fnamencmp(path + (s - buf), dp->d_name, e - s) == 0)))
{
STRCPY(s, dp->d_name);
len = STRLEN(buf);
if (starstar && stardepth < 100)
{
// For "**" in the pattern first go deeper in the tree to
// find matches.
STRCPY(buf + len, "/**");
STRCPY(buf + len + 3, path_end);
++stardepth;
(void)unix_expandpath(gap, buf, len + 1, flags, TRUE);
--stardepth;
}
STRCPY(buf + len, path_end);
if (mch_has_exp_wildcard(path_end)) // handle more wildcards
{
// need to expand another component of the path
// remove backslashes for the remaining components only
(void)unix_expandpath(gap, buf, len + 1, flags, FALSE);
}
else
{
stat_T sb;
// no more wildcards, check if there is a match
// remove backslashes for the remaining components only
if (*path_end != NUL)
backslash_halve(buf + len + 1);
// add existing file or symbolic link
if ((flags & EW_ALLLINKS) ? mch_lstat((char *)buf, &sb) >= 0
: mch_getperm(buf) >= 0)
{
#ifdef MACOS_CONVERT
size_t precomp_len = STRLEN(buf)+1;
char_u *precomp_buf =
mac_precompose_path(buf, precomp_len, &precomp_len);
if (precomp_buf)
{
mch_memmove(buf, precomp_buf, precomp_len);
vim_free(precomp_buf);
}
#endif
addfile(gap, buf, flags);
}
}
}
}
closedir(dirp);
}
vim_free(buf);
vim_regfree(regmatch.regprog);
matches = gap->ga_len - start_len;
if (matches > 0)
qsort(((char_u **)gap->ga_data) + start_len, matches,
sizeof(char_u *), pstrcmp);
return matches;
}
| 1
|
310,155
|
_nc_mouse_event(SCREEN *sp)
{
MEVENT *eventp = sp->_mouse_eventp;
bool result = FALSE;
(void) eventp;
switch (sp->_mouse_type) {
case M_XTERM:
/* xterm: never have to query, mouse events are in the keyboard stream */
#if USE_EMX_MOUSE
{
char kbuf[3];
int i, res = read(M_FD(sp), &kbuf, 3); /* Eat the prefix */
if (res != 3)
printf("Got %d chars instead of 3 for prefix.\n", res);
for (i = 0; i < res; i++) {
if (kbuf[i] != key_mouse[i])
printf("Got char %d instead of %d for prefix.\n",
(int) kbuf[i], (int) key_mouse[i]);
}
result = TRUE;
}
#endif /* USE_EMX_MOUSE */
break;
#if USE_GPM_SUPPORT
case M_GPM:
if (sp->_mouse_fd >= 0) {
/* query server for event, return TRUE if we find one */
Gpm_Event ev;
switch (my_Gpm_GetEvent(&ev)) {
case 0:
/* Connection closed, drop the mouse. */
sp->_mouse_fd = -1;
break;
case 1:
/* there's only one mouse... */
eventp->id = NORMAL_EVENT;
eventp->bstate = 0;
switch (ev.type & 0x0f) {
case (GPM_DOWN):
if (ev.buttons & GPM_B_LEFT)
eventp->bstate |= BUTTON1_PRESSED;
if (ev.buttons & GPM_B_MIDDLE)
eventp->bstate |= BUTTON2_PRESSED;
if (ev.buttons & GPM_B_RIGHT)
eventp->bstate |= BUTTON3_PRESSED;
break;
case (GPM_UP):
if (ev.buttons & GPM_B_LEFT)
eventp->bstate |= BUTTON1_RELEASED;
if (ev.buttons & GPM_B_MIDDLE)
eventp->bstate |= BUTTON2_RELEASED;
if (ev.buttons & GPM_B_RIGHT)
eventp->bstate |= BUTTON3_RELEASED;
break;
default:
eventp->bstate |= REPORT_MOUSE_POSITION;
break;
}
eventp->x = ev.x - 1;
eventp->y = ev.y - 1;
eventp->z = 0;
/* bump the next-free pointer into the circular list */
sp->_mouse_eventp = NEXT(eventp);
result = TRUE;
break;
}
}
break;
#endif
#if USE_SYSMOUSE
case M_SYSMOUSE:
if (sp->_sysmouse_head < sp->_sysmouse_tail) {
*eventp = sp->_sysmouse_fifo[sp->_sysmouse_head];
/*
* Point the fifo-head to the next possible location. If there
* are none, reset the indices. This may be interrupted by the
* signal handler, doing essentially the same reset.
*/
sp->_sysmouse_head += 1;
if (sp->_sysmouse_head == sp->_sysmouse_tail) {
sp->_sysmouse_tail = 0;
sp->_sysmouse_head = 0;
}
/* bump the next-free pointer into the circular list */
sp->_mouse_eventp = eventp = NEXT(eventp);
result = TRUE;
}
break;
#endif /* USE_SYSMOUSE */
#ifdef USE_TERM_DRIVER
case M_TERM_DRIVER:
while (sp->_drv_mouse_head < sp->_drv_mouse_tail) {
*eventp = sp->_drv_mouse_fifo[sp->_drv_mouse_head];
/*
* Point the fifo-head to the next possible location. If there
* are none, reset the indices.
*/
sp->_drv_mouse_head += 1;
if (sp->_drv_mouse_head == sp->_drv_mouse_tail) {
sp->_drv_mouse_tail = 0;
sp->_drv_mouse_head = 0;
}
/* bump the next-free pointer into the circular list */
sp->_mouse_eventp = eventp = NEXT(eventp);
result = TRUE;
}
break;
#endif
case M_NONE:
break;
}
return result; /* true if we found an event */
}
| 0
|
393,518
|
static SQInteger array_insert(HSQUIRRELVM v)
{
SQObject &o=stack_get(v,1);
SQObject &idx=stack_get(v,2);
SQObject &val=stack_get(v,3);
if(!_array(o)->Insert(tointeger(idx),val))
return sq_throwerror(v,_SC("index out of range"));
sq_pop(v,2);
return 1;
}
| 0
|
359,337
|
DEFUN (clear_bgp_peer_group_soft,
clear_bgp_peer_group_soft_cmd,
"clear bgp peer-group WORD soft",
CLEAR_STR
BGP_STR
"Clear all members of peer-group\n"
"BGP peer-group name\n"
"Soft reconfig\n")
{
return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
BGP_CLEAR_SOFT_BOTH, argv[0]);
}
| 0
|
225,825
|
void sdp_box_del(GF_Box *s)
{
GF_SDPBox *ptr = (GF_SDPBox *)s;
if (ptr->sdpText) gf_free(ptr->sdpText);
gf_free(ptr);
}
| 0
|
233,815
|
void fmtutil_handle_id3(deark *c, dbuf *f, struct de_id3info *id3i,
unsigned int flags)
{
i64 id3v1pos = 0;
int look_for_id3v1;
de_zeromem(id3i, sizeof(struct de_id3info));
id3i->main_start = 0;
id3i->main_end = f->len;
id3i->has_id3v2 = !dbuf_memcmp(f, 0, "ID3", 3);
if(id3i->has_id3v2) {
de_module_params id3v2mparams;
de_dbg(c, "ID3v2 data at %d", 0);
de_dbg_indent(c, 1);
de_zeromem(&id3v2mparams, sizeof(de_module_params));
id3v2mparams.in_params.codes = "I";
de_run_module_by_id_on_slice(c, "id3", &id3v2mparams, f, 0, f->len);
de_dbg_indent(c, -1);
id3i->main_start += id3v2mparams.out_params.int64_1;
}
look_for_id3v1 = 1;
if(look_for_id3v1) {
id3v1pos = f->len-128;
if(!dbuf_memcmp(f, id3v1pos, "TAG", 3)) {
id3i->has_id3v1 = 1;
}
}
if(id3i->has_id3v1) {
de_module_params id3v1mparams;
de_dbg(c, "ID3v1 data at %"I64_FMT, id3v1pos);
de_dbg_indent(c, 1);
de_zeromem(&id3v1mparams, sizeof(de_module_params));
id3v1mparams.in_params.codes = "1";
de_run_module_by_id_on_slice(c, "id3", &id3v1mparams, f, id3v1pos, 128);
de_dbg_indent(c, -1);
id3i->main_end = id3v1pos;
}
}
| 0
|
336,498
|
static void reds_handle_auth_mechanism(void *opaque)
{
RedLinkInfo *link = (RedLinkInfo *)opaque;
RedsState *reds = link->reds;
spice_debug("Auth method: %d", link->auth_mechanism.auth_mechanism);
link->auth_mechanism.auth_mechanism = GUINT32_FROM_LE(link->auth_mechanism.auth_mechanism);
if (link->auth_mechanism.auth_mechanism == SPICE_COMMON_CAP_AUTH_SPICE
&& !reds->config->sasl_enabled
) {
reds_get_spice_ticket(link);
#if HAVE_SASL
} else if (link->auth_mechanism.auth_mechanism == SPICE_COMMON_CAP_AUTH_SASL) {
spice_debug("Starting SASL");
reds_start_auth_sasl(link);
#endif
} else {
spice_warning("Unknown auth method, disconnecting");
if (reds->config->sasl_enabled) {
spice_warning("Your client doesn't handle SASL?");
}
reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);
reds_link_free(link);
}
}
| 0
|
209,955
|
struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
const struct pci_device_id *ent,
const struct iwl_cfg_trans_params *cfg_trans)
{
struct iwl_trans_pcie *trans_pcie;
struct iwl_trans *trans;
int ret, addr_size;
ret = pcim_enable_device(pdev);
if (ret)
return ERR_PTR(ret);
if (cfg_trans->gen2)
trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie),
&pdev->dev, &trans_ops_pcie_gen2);
else
trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie),
&pdev->dev, &trans_ops_pcie);
if (!trans)
return ERR_PTR(-ENOMEM);
trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
trans_pcie->trans = trans;
trans_pcie->opmode_down = true;
spin_lock_init(&trans_pcie->irq_lock);
spin_lock_init(&trans_pcie->reg_lock);
mutex_init(&trans_pcie->mutex);
init_waitqueue_head(&trans_pcie->ucode_write_waitq);
trans_pcie->tso_hdr_page = alloc_percpu(struct iwl_tso_hdr_page);
if (!trans_pcie->tso_hdr_page) {
ret = -ENOMEM;
goto out_no_pci;
}
trans_pcie->debug_rfkill = -1;
if (!cfg_trans->base_params->pcie_l1_allowed) {
/*
* W/A - seems to solve weird behavior. We need to remove this
* if we don't want to stay in L1 all the time. This wastes a
* lot of power.
*/
pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S |
PCIE_LINK_STATE_L1 |
PCIE_LINK_STATE_CLKPM);
}
trans_pcie->def_rx_queue = 0;
if (cfg_trans->use_tfh) {
addr_size = 64;
trans_pcie->max_tbs = IWL_TFH_NUM_TBS;
trans_pcie->tfd_size = sizeof(struct iwl_tfh_tfd);
} else {
addr_size = 36;
trans_pcie->max_tbs = IWL_NUM_OF_TBS;
trans_pcie->tfd_size = sizeof(struct iwl_tfd);
}
trans->max_skb_frags = IWL_PCIE_MAX_FRAGS(trans_pcie);
pci_set_master(pdev);
ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(addr_size));
if (!ret)
ret = pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(addr_size));
if (ret) {
ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (!ret)
ret = pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(32));
/* both attempts failed: */
if (ret) {
dev_err(&pdev->dev, "No suitable DMA available\n");
goto out_no_pci;
}
}
ret = pcim_iomap_regions_request_all(pdev, BIT(0), DRV_NAME);
if (ret) {
dev_err(&pdev->dev, "pcim_iomap_regions_request_all failed\n");
goto out_no_pci;
}
trans_pcie->hw_base = pcim_iomap_table(pdev)[0];
if (!trans_pcie->hw_base) {
dev_err(&pdev->dev, "pcim_iomap_table failed\n");
ret = -ENODEV;
goto out_no_pci;
}
/* We disable the RETRY_TIMEOUT register (0x41) to keep
* PCI Tx retries from interfering with C3 CPU state */
pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);
trans_pcie->pci_dev = pdev;
iwl_disable_interrupts(trans);
trans->hw_rev = iwl_read32(trans, CSR_HW_REV);
if (trans->hw_rev == 0xffffffff) {
dev_err(&pdev->dev, "HW_REV=0xFFFFFFFF, PCI issues?\n");
ret = -EIO;
goto out_no_pci;
}
/*
* In the 8000 HW family the format of the 4 bytes of CSR_HW_REV have
* changed, and now the revision step also includes bit 0-1 (no more
* "dash" value). To keep hw_rev backwards compatible - we'll store it
* in the old format.
*/
if (cfg_trans->device_family >= IWL_DEVICE_FAMILY_8000) {
trans->hw_rev = (trans->hw_rev & 0xfff0) |
(CSR_HW_REV_STEP(trans->hw_rev << 2) << 2);
ret = iwl_pcie_prepare_card_hw(trans);
if (ret) {
IWL_WARN(trans, "Exit HW not ready\n");
goto out_no_pci;
}
/*
* in-order to recognize C step driver should read chip version
* id located at the AUX bus MISC address space.
*/
ret = iwl_finish_nic_init(trans, cfg_trans);
if (ret)
goto out_no_pci;
}
IWL_DEBUG_INFO(trans, "HW REV: 0x%0x\n", trans->hw_rev);
iwl_pcie_set_interrupt_capa(pdev, trans, cfg_trans);
trans->hw_id = (pdev->device << 16) + pdev->subsystem_device;
snprintf(trans->hw_id_str, sizeof(trans->hw_id_str),
"PCI ID: 0x%04X:0x%04X", pdev->device, pdev->subsystem_device);
/* Initialize the wait queue for commands */
init_waitqueue_head(&trans_pcie->wait_command_queue);
init_waitqueue_head(&trans_pcie->sx_waitq);
if (trans_pcie->msix_enabled) {
ret = iwl_pcie_init_msix_handler(pdev, trans_pcie);
if (ret)
goto out_no_pci;
} else {
ret = iwl_pcie_alloc_ict(trans);
if (ret)
goto out_no_pci;
ret = devm_request_threaded_irq(&pdev->dev, pdev->irq,
iwl_pcie_isr,
iwl_pcie_irq_handler,
IRQF_SHARED, DRV_NAME, trans);
if (ret) {
IWL_ERR(trans, "Error allocating IRQ %d\n", pdev->irq);
goto out_free_ict;
}
trans_pcie->inta_mask = CSR_INI_SET_MASK;
}
trans_pcie->rba.alloc_wq = alloc_workqueue("rb_allocator",
WQ_HIGHPRI | WQ_UNBOUND, 1);
INIT_WORK(&trans_pcie->rba.rx_alloc, iwl_pcie_rx_allocator_work);
#ifdef CONFIG_IWLWIFI_DEBUGFS
trans_pcie->fw_mon_data.state = IWL_FW_MON_DBGFS_STATE_CLOSED;
mutex_init(&trans_pcie->fw_mon_data.mutex);
#endif
return trans;
out_free_ict:
iwl_pcie_free_ict(trans);
out_no_pci:
free_percpu(trans_pcie->tso_hdr_page);
iwl_trans_free(trans);
return ERR_PTR(ret);
}
| 1
|
210,692
|
static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
BMPInfo
bmp_info;
Image
*image;
IndexPacket
index;
MagickBooleanType
status;
MagickOffsetType
offset,
start_position;
MemoryInfo
*pixel_info;
register IndexPacket
*indexes;
register PixelPacket
*q;
register ssize_t
i,
x;
register unsigned char
*p;
size_t
bit,
bytes_per_line,
length;
ssize_t
count,
y;
unsigned char
magick[12],
*pixels;
unsigned int
blue,
green,
offset_bits,
red;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Determine if this a BMP file.
*/
(void) memset(&bmp_info,0,sizeof(bmp_info));
bmp_info.ba_offset=0;
start_position=0;
offset_bits=0;
count=ReadBlob(image,2,magick);
if (count != 2)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
do
{
LongPixelPacket
shift;
PixelPacket
quantum_bits;
/*
Verify BMP identifier.
*/
if (bmp_info.ba_offset == 0)
start_position=TellBlob(image)-2;
bmp_info.ba_offset=0;
while (LocaleNCompare((char *) magick,"BA",2) == 0)
{
bmp_info.file_size=ReadBlobLSBLong(image);
bmp_info.ba_offset=ReadBlobLSBLong(image);
bmp_info.offset_bits=ReadBlobLSBLong(image);
count=ReadBlob(image,2,magick);
if (count != 2)
break;
}
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule()," Magick: %c%c",
magick[0],magick[1]);
if ((count != 2) || ((LocaleNCompare((char *) magick,"BM",2) != 0) &&
(LocaleNCompare((char *) magick,"CI",2) != 0)))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
bmp_info.file_size=ReadBlobLSBLong(image);
(void) ReadBlobLSBLong(image);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" File_size in header: %u bytes",bmp_info.file_size);
bmp_info.offset_bits=ReadBlobLSBLong(image);
bmp_info.size=ReadBlobLSBLong(image);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule()," BMP size: %u",
bmp_info.size);
if (bmp_info.size == 12)
{
/*
OS/2 BMP image file.
*/
(void) CopyMagickString(image->magick,"BMP2",MaxTextExtent);
bmp_info.width=(ssize_t) ((short) ReadBlobLSBShort(image));
bmp_info.height=(ssize_t) ((short) ReadBlobLSBShort(image));
bmp_info.planes=ReadBlobLSBShort(image);
bmp_info.bits_per_pixel=ReadBlobLSBShort(image);
bmp_info.x_pixels=0;
bmp_info.y_pixels=0;
bmp_info.number_colors=0;
bmp_info.compression=BI_RGB;
bmp_info.image_size=0;
bmp_info.alpha_mask=0;
if (image->debug != MagickFalse)
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Format: OS/2 Bitmap");
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Geometry: %.20gx%.20g",(double) bmp_info.width,(double)
bmp_info.height);
}
}
else
{
/*
Microsoft Windows BMP image file.
*/
if (bmp_info.size < 40)
ThrowReaderException(CorruptImageError,"NonOS2HeaderSizeError");
bmp_info.width=(ssize_t) ReadBlobLSBSignedLong(image);
bmp_info.height=(ssize_t) ReadBlobLSBSignedLong(image);
bmp_info.planes=ReadBlobLSBShort(image);
bmp_info.bits_per_pixel=ReadBlobLSBShort(image);
bmp_info.compression=ReadBlobLSBLong(image);
bmp_info.image_size=ReadBlobLSBLong(image);
bmp_info.x_pixels=ReadBlobLSBLong(image);
bmp_info.y_pixels=ReadBlobLSBLong(image);
bmp_info.number_colors=ReadBlobLSBLong(image);
if (bmp_info.number_colors > GetBlobSize(image))
ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
bmp_info.colors_important=ReadBlobLSBLong(image);
if (image->debug != MagickFalse)
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Format: MS Windows bitmap");
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Geometry: %.20gx%.20g",(double) bmp_info.width,(double)
bmp_info.height);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Bits per pixel: %.20g",(double) bmp_info.bits_per_pixel);
switch (bmp_info.compression)
{
case BI_RGB:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: BI_RGB");
break;
}
case BI_RLE4:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: BI_RLE4");
break;
}
case BI_RLE8:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: BI_RLE8");
break;
}
case BI_BITFIELDS:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: BI_BITFIELDS");
break;
}
case BI_PNG:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: BI_PNG");
break;
}
case BI_JPEG:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: BI_JPEG");
break;
}
default:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: UNKNOWN (%u)",bmp_info.compression);
}
}
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Number of colors: %u",bmp_info.number_colors);
}
bmp_info.red_mask=ReadBlobLSBLong(image);
bmp_info.green_mask=ReadBlobLSBLong(image);
bmp_info.blue_mask=ReadBlobLSBLong(image);
if (bmp_info.size > 40)
{
double
gamma;
/*
Read color management information.
*/
bmp_info.alpha_mask=ReadBlobLSBLong(image);
bmp_info.colorspace=ReadBlobLSBSignedLong(image);
/*
Decode 2^30 fixed point formatted CIE primaries.
*/
# define BMP_DENOM ((double) 0x40000000)
bmp_info.red_primary.x=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.red_primary.y=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.red_primary.z=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.green_primary.x=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.green_primary.y=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.green_primary.z=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.blue_primary.x=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.blue_primary.y=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.blue_primary.z=(double) ReadBlobLSBLong(image)/BMP_DENOM;
gamma=bmp_info.red_primary.x+bmp_info.red_primary.y+
bmp_info.red_primary.z;
gamma=PerceptibleReciprocal(gamma);
bmp_info.red_primary.x*=gamma;
bmp_info.red_primary.y*=gamma;
image->chromaticity.red_primary.x=bmp_info.red_primary.x;
image->chromaticity.red_primary.y=bmp_info.red_primary.y;
gamma=bmp_info.green_primary.x+bmp_info.green_primary.y+
bmp_info.green_primary.z;
gamma=PerceptibleReciprocal(gamma);
bmp_info.green_primary.x*=gamma;
bmp_info.green_primary.y*=gamma;
image->chromaticity.green_primary.x=bmp_info.green_primary.x;
image->chromaticity.green_primary.y=bmp_info.green_primary.y;
gamma=bmp_info.blue_primary.x+bmp_info.blue_primary.y+
bmp_info.blue_primary.z;
gamma=PerceptibleReciprocal(gamma);
bmp_info.blue_primary.x*=gamma;
bmp_info.blue_primary.y*=gamma;
image->chromaticity.blue_primary.x=bmp_info.blue_primary.x;
image->chromaticity.blue_primary.y=bmp_info.blue_primary.y;
/*
Decode 16^16 fixed point formatted gamma_scales.
*/
bmp_info.gamma_scale.x=(double) ReadBlobLSBLong(image)/0x10000;
bmp_info.gamma_scale.y=(double) ReadBlobLSBLong(image)/0x10000;
bmp_info.gamma_scale.z=(double) ReadBlobLSBLong(image)/0x10000;
/*
Compute a single gamma from the BMP 3-channel gamma.
*/
image->gamma=(bmp_info.gamma_scale.x+bmp_info.gamma_scale.y+
bmp_info.gamma_scale.z)/3.0;
}
else
(void) CopyMagickString(image->magick,"BMP3",MaxTextExtent);
if (bmp_info.size > 108)
{
size_t
intent;
/*
Read BMP Version 5 color management information.
*/
intent=ReadBlobLSBLong(image);
switch ((int) intent)
{
case LCS_GM_BUSINESS:
{
image->rendering_intent=SaturationIntent;
break;
}
case LCS_GM_GRAPHICS:
{
image->rendering_intent=RelativeIntent;
break;
}
case LCS_GM_IMAGES:
{
image->rendering_intent=PerceptualIntent;
break;
}
case LCS_GM_ABS_COLORIMETRIC:
{
image->rendering_intent=AbsoluteIntent;
break;
}
}
(void) ReadBlobLSBLong(image); /* Profile data */
(void) ReadBlobLSBLong(image); /* Profile size */
(void) ReadBlobLSBLong(image); /* Reserved byte */
}
}
if ((MagickSizeType) bmp_info.file_size > GetBlobSize(image))
(void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
"LengthAndFilesizeDoNotMatch","`%s'",image->filename);
else
if ((MagickSizeType) bmp_info.file_size < GetBlobSize(image))
(void) ThrowMagickException(exception,GetMagickModule(),
CorruptImageWarning,"LengthAndFilesizeDoNotMatch","`%s'",
image->filename);
if (bmp_info.width <= 0)
ThrowReaderException(CorruptImageError,"NegativeOrZeroImageSize");
if (bmp_info.height == 0)
ThrowReaderException(CorruptImageError,"NegativeOrZeroImageSize");
if (bmp_info.planes != 1)
ThrowReaderException(CorruptImageError,"StaticPlanesValueNotEqualToOne");
if ((bmp_info.bits_per_pixel != 1) && (bmp_info.bits_per_pixel != 4) &&
(bmp_info.bits_per_pixel != 8) && (bmp_info.bits_per_pixel != 16) &&
(bmp_info.bits_per_pixel != 24) && (bmp_info.bits_per_pixel != 32))
ThrowReaderException(CorruptImageError,"UnrecognizedBitsPerPixel");
if (bmp_info.bits_per_pixel < 16 &&
bmp_info.number_colors > (1U << bmp_info.bits_per_pixel))
ThrowReaderException(CorruptImageError,"UnrecognizedNumberOfColors");
if ((bmp_info.compression == 1) && (bmp_info.bits_per_pixel != 8))
ThrowReaderException(CorruptImageError,"UnrecognizedBitsPerPixel");
if ((bmp_info.compression == 2) && (bmp_info.bits_per_pixel != 4))
ThrowReaderException(CorruptImageError,"UnrecognizedBitsPerPixel");
if ((bmp_info.compression == 3) && (bmp_info.bits_per_pixel < 16))
ThrowReaderException(CorruptImageError,"UnrecognizedBitsPerPixel");
switch (bmp_info.compression)
{
case BI_RGB:
image->compression=NoCompression;
break;
case BI_RLE8:
case BI_RLE4:
image->compression=RLECompression;
break;
case BI_BITFIELDS:
break;
case BI_JPEG:
ThrowReaderException(CoderError,"JPEGCompressNotSupported");
case BI_PNG:
ThrowReaderException(CoderError,"PNGCompressNotSupported");
default:
ThrowReaderException(CorruptImageError,"UnrecognizedImageCompression");
}
image->columns=(size_t) MagickAbsoluteValue(bmp_info.width);
image->rows=(size_t) MagickAbsoluteValue(bmp_info.height);
image->depth=bmp_info.bits_per_pixel <= 8 ? bmp_info.bits_per_pixel : 8;
image->matte=((bmp_info.alpha_mask != 0) &&
(bmp_info.compression == BI_BITFIELDS)) ? MagickTrue : MagickFalse;
if (bmp_info.bits_per_pixel < 16)
{
size_t
one;
image->storage_class=PseudoClass;
image->colors=bmp_info.number_colors;
one=1;
if (image->colors == 0)
image->colors=one << bmp_info.bits_per_pixel;
}
image->x_resolution=(double) bmp_info.x_pixels/100.0;
image->y_resolution=(double) bmp_info.y_pixels/100.0;
image->units=PixelsPerCentimeterResolution;
if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
status=SetImageExtent(image,image->columns,image->rows);
if (status == MagickFalse)
{
InheritException(exception,&image->exception);
return(DestroyImageList(image));
}
if (image->storage_class == PseudoClass)
{
unsigned char
*bmp_colormap;
size_t
packet_size;
/*
Read BMP raster colormap.
*/
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Reading colormap of %.20g colors",(double) image->colors);
if (AcquireImageColormap(image,image->colors) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
bmp_colormap=(unsigned char *) AcquireQuantumMemory((size_t)
image->colors,4*sizeof(*bmp_colormap));
if (bmp_colormap == (unsigned char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if ((bmp_info.size == 12) || (bmp_info.size == 64))
packet_size=3;
else
packet_size=4;
offset=SeekBlob(image,start_position+14+bmp_info.size,SEEK_SET);
if (offset < 0)
{
bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
}
count=ReadBlob(image,packet_size*image->colors,bmp_colormap);
if (count != (ssize_t) (packet_size*image->colors))
{
bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);
ThrowReaderException(CorruptImageError,
"InsufficientImageDataInFile");
}
p=bmp_colormap;
for (i=0; i < (ssize_t) image->colors; i++)
{
image->colormap[i].blue=ScaleCharToQuantum(*p++);
image->colormap[i].green=ScaleCharToQuantum(*p++);
image->colormap[i].red=ScaleCharToQuantum(*p++);
if (packet_size == 4)
p++;
}
bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);
}
/*
Read image data.
*/
if (bmp_info.offset_bits == offset_bits)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
offset_bits=bmp_info.offset_bits;
offset=SeekBlob(image,start_position+bmp_info.offset_bits,SEEK_SET);
if (offset < 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
if (bmp_info.compression == BI_RLE4)
bmp_info.bits_per_pixel<<=1;
bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)/32);
length=(size_t) bytes_per_line*image->rows;
if (((MagickSizeType) length/8) > GetBlobSize(image))
ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
if ((bmp_info.compression == BI_RGB) ||
(bmp_info.compression == BI_BITFIELDS))
{
pixel_info=AcquireVirtualMemory(image->rows,MagickMax(bytes_per_line,
image->columns+256UL)*sizeof(*pixels));
if (pixel_info == (MemoryInfo *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Reading pixels (%.20g bytes)",(double) length);
count=ReadBlob(image,length,pixels);
if (count != (ssize_t) length)
{
pixel_info=RelinquishVirtualMemory(pixel_info);
ThrowReaderException(CorruptImageError,
"InsufficientImageDataInFile");
}
}
else
{
/*
Convert run-length encoded raster pixels.
*/
pixel_info=AcquireVirtualMemory(image->rows,MagickMax(bytes_per_line,
image->columns+256UL)*sizeof(*pixels));
if (pixel_info == (MemoryInfo *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);
status=DecodeImage(image,bmp_info.compression,pixels,
image->columns*image->rows);
if (status == MagickFalse)
{
pixel_info=RelinquishVirtualMemory(pixel_info);
ThrowReaderException(CorruptImageError,
"UnableToRunlengthDecodeImage");
}
}
/*
Convert BMP raster image to pixel packets.
*/
if (bmp_info.compression == BI_RGB)
{
/*
We should ignore the alpha value in BMP3 files but there have been
reports about 32 bit files with alpha. We do a quick check to see if
the alpha channel contains a value that is not zero (default value).
If we find a non zero value we asume the program that wrote the file
wants to use the alpha channel.
*/
if ((image->matte == MagickFalse) && (bmp_info.size == 40) &&
(bmp_info.bits_per_pixel == 32))
{
bytes_per_line=4*(image->columns);
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=pixels+(image->rows-y-1)*bytes_per_line;
for (x=0; x < (ssize_t) image->columns; x++)
{
if (*(p+3) != 0)
{
image->matte=MagickTrue;
y=-1;
break;
}
p+=4;
}
}
}
bmp_info.alpha_mask=image->matte != MagickFalse ? 0xff000000U : 0U;
bmp_info.red_mask=0x00ff0000U;
bmp_info.green_mask=0x0000ff00U;
bmp_info.blue_mask=0x000000ffU;
if (bmp_info.bits_per_pixel == 16)
{
/*
RGB555.
*/
bmp_info.red_mask=0x00007c00U;
bmp_info.green_mask=0x000003e0U;
bmp_info.blue_mask=0x0000001fU;
}
}
(void) memset(&shift,0,sizeof(shift));
(void) memset(&quantum_bits,0,sizeof(quantum_bits));
if ((bmp_info.bits_per_pixel == 16) || (bmp_info.bits_per_pixel == 32))
{
register size_t
sample;
/*
Get shift and quantum bits info from bitfield masks.
*/
if (bmp_info.red_mask != 0)
while (((bmp_info.red_mask << shift.red) & 0x80000000UL) == 0)
{
shift.red++;
if (shift.red > 32U)
break;
}
if (bmp_info.green_mask != 0)
while (((bmp_info.green_mask << shift.green) & 0x80000000UL) == 0)
{
shift.green++;
if (shift.green > 32U)
break;
}
if (bmp_info.blue_mask != 0)
while (((bmp_info.blue_mask << shift.blue) & 0x80000000UL) == 0)
{
shift.blue++;
if (shift.blue > 32U)
break;
}
if (bmp_info.alpha_mask != 0)
while (((bmp_info.alpha_mask << shift.opacity) & 0x80000000UL) == 0)
{
shift.opacity++;
if (shift.opacity > 32U)
break;
}
sample=shift.red;
while (((bmp_info.red_mask << sample) & 0x80000000UL) != 0)
{
sample++;
if (sample > 32U)
break;
}
quantum_bits.red=ClampToQuantum((MagickRealType) sample-shift.red);
sample=shift.green;
while (((bmp_info.green_mask << sample) & 0x80000000UL) != 0)
{
sample++;
if (sample > 32U)
break;
}
quantum_bits.green=ClampToQuantum((MagickRealType) sample-shift.green);
sample=shift.blue;
while (((bmp_info.blue_mask << sample) & 0x80000000UL) != 0)
{
sample++;
if (sample > 32U)
break;
}
quantum_bits.blue=ClampToQuantum((MagickRealType) sample-shift.blue);
sample=shift.opacity;
while (((bmp_info.alpha_mask << sample) & 0x80000000UL) != 0)
{
sample++;
if (sample > 32U)
break;
}
quantum_bits.opacity=ClampToQuantum((MagickRealType) sample-
shift.opacity);
}
switch (bmp_info.bits_per_pixel)
{
case 1:
{
/*
Convert bitmap scanline.
*/
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=pixels+(image->rows-y-1)*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
for (x=0; x < ((ssize_t) image->columns-7); x+=8)
{
for (bit=0; bit < 8; bit++)
{
index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);
SetPixelIndex(indexes+x+bit,index);
q++;
}
p++;
}
if ((image->columns % 8) != 0)
{
for (bit=0; bit < (image->columns % 8); bit++)
{
index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);
SetPixelIndex(indexes+x+bit,index);
}
p++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
(image->rows-y),image->rows);
if (status == MagickFalse)
break;
}
}
(void) SyncImage(image);
break;
}
case 4:
{
/*
Convert PseudoColor scanline.
*/
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=pixels+(image->rows-y-1)*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
for (x=0; x < ((ssize_t) image->columns-1); x+=2)
{
(void) IsValidColormapIndex(image,(ssize_t) ((*p >> 4) & 0x0f),
&index,exception);
SetPixelIndex(indexes+x,index);
(void) IsValidColormapIndex(image,(ssize_t) (*p & 0x0f),&index,
exception);
SetPixelIndex(indexes+x+1,index);
p++;
}
if ((image->columns % 2) != 0)
{
(void) IsValidColormapIndex(image,(ssize_t) ((*p >> 4) & 0xf),
&index,exception);
SetPixelIndex(indexes+(x++),index);
p++;
}
if (x < (ssize_t) image->columns)
break;
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
(image->rows-y),image->rows);
if (status == MagickFalse)
break;
}
}
(void) SyncImage(image);
break;
}
case 8:
{
/*
Convert PseudoColor scanline.
*/
if ((bmp_info.compression == BI_RLE8) ||
(bmp_info.compression == BI_RLE4))
bytes_per_line=image->columns;
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=pixels+(image->rows-y-1)*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
for (x=(ssize_t) image->columns; x != 0; --x)
{
(void) IsValidColormapIndex(image,(ssize_t) *p,&index,exception);
SetPixelIndex(indexes,index);
indexes++;
p++;
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
offset=(MagickOffsetType) (image->rows-y-1);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
(image->rows-y),image->rows);
if (status == MagickFalse)
break;
}
}
(void) SyncImage(image);
break;
}
case 16:
{
unsigned int
alpha,
pixel;
/*
Convert bitfield encoded 16-bit PseudoColor scanline.
*/
if (bmp_info.compression != BI_RGB &&
bmp_info.compression != BI_BITFIELDS)
{
pixel_info=RelinquishVirtualMemory(pixel_info);
ThrowReaderException(CorruptImageError,
"UnrecognizedImageCompression");
}
bytes_per_line=2*(image->columns+image->columns % 2);
image->storage_class=DirectClass;
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=pixels+(image->rows-y-1)*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
pixel=(unsigned int) (*p++);
pixel|=(*p++) << 8;
red=((pixel & bmp_info.red_mask) << shift.red) >> 16;
if (quantum_bits.red == 5)
red|=((red & 0xe000) >> 5);
if (quantum_bits.red <= 8)
red|=((red & 0xff00) >> 8);
green=((pixel & bmp_info.green_mask) << shift.green) >> 16;
if (quantum_bits.green == 5)
green|=((green & 0xe000) >> 5);
if (quantum_bits.green == 6)
green|=((green & 0xc000) >> 6);
if (quantum_bits.green <= 8)
green|=((green & 0xff00) >> 8);
blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16;
if (quantum_bits.blue == 5)
blue|=((blue & 0xe000) >> 5);
if (quantum_bits.blue <= 8)
blue|=((blue & 0xff00) >> 8);
SetPixelRed(q,ScaleShortToQuantum((unsigned short) red));
SetPixelGreen(q,ScaleShortToQuantum((unsigned short) green));
SetPixelBlue(q,ScaleShortToQuantum((unsigned short) blue));
SetPixelOpacity(q,OpaqueOpacity);
if (image->matte != MagickFalse)
{
alpha=((pixel & bmp_info.alpha_mask) << shift.opacity) >> 16;
if (quantum_bits.opacity <= 8)
alpha|=((alpha & 0xff00) >> 8);
SetPixelAlpha(q,ScaleShortToQuantum((unsigned short) alpha));
}
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
offset=(MagickOffsetType) (image->rows-y-1);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
(image->rows-y),image->rows);
if (status == MagickFalse)
break;
}
}
break;
}
case 24:
{
/*
Convert DirectColor scanline.
*/
bytes_per_line=4*((image->columns*24+31)/32);
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=pixels+(image->rows-y-1)*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelBlue(q,ScaleCharToQuantum(*p++));
SetPixelGreen(q,ScaleCharToQuantum(*p++));
SetPixelRed(q,ScaleCharToQuantum(*p++));
SetPixelOpacity(q,OpaqueOpacity);
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
offset=(MagickOffsetType) (image->rows-y-1);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
(image->rows-y),image->rows);
if (status == MagickFalse)
break;
}
}
break;
}
case 32:
{
/*
Convert bitfield encoded DirectColor scanline.
*/
if ((bmp_info.compression != BI_RGB) &&
(bmp_info.compression != BI_BITFIELDS))
{
pixel_info=RelinquishVirtualMemory(pixel_info);
ThrowReaderException(CorruptImageError,
"UnrecognizedImageCompression");
}
bytes_per_line=4*(image->columns);
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
unsigned int
alpha,
pixel;
p=pixels+(image->rows-y-1)*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
pixel=(unsigned int) (*p++);
pixel|=((unsigned int) *p++ << 8);
pixel|=((unsigned int) *p++ << 16);
pixel|=((unsigned int) *p++ << 24);
red=((pixel & bmp_info.red_mask) << shift.red) >> 16;
if (quantum_bits.red == 8)
red|=(red >> 8);
green=((pixel & bmp_info.green_mask) << shift.green) >> 16;
if (quantum_bits.green == 8)
green|=(green >> 8);
blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16;
if (quantum_bits.blue == 8)
blue|=(blue >> 8);
SetPixelRed(q,ScaleShortToQuantum((unsigned short) red));
SetPixelGreen(q,ScaleShortToQuantum((unsigned short) green));
SetPixelBlue(q,ScaleShortToQuantum((unsigned short) blue));
SetPixelAlpha(q,OpaqueOpacity);
if (image->matte != MagickFalse)
{
alpha=((pixel & bmp_info.alpha_mask) << shift.opacity) >> 16;
if (quantum_bits.opacity == 8)
alpha|=(alpha >> 8);
SetPixelAlpha(q,ScaleShortToQuantum((unsigned short) alpha));
}
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
offset=(MagickOffsetType) (image->rows-y-1);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
(image->rows-y),image->rows);
if (status == MagickFalse)
break;
}
}
break;
}
default:
{
pixel_info=RelinquishVirtualMemory(pixel_info);
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
}
}
pixel_info=RelinquishVirtualMemory(pixel_info);
if (y > 0)
break;
if (EOFBlob(image) != MagickFalse)
{
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
break;
}
if (bmp_info.height < 0)
{
Image
*flipped_image;
/*
Correct image orientation.
*/
flipped_image=FlipImage(image,exception);
if (flipped_image != (Image *) NULL)
{
DuplicateBlob(flipped_image,image);
ReplaceImageInList(&image, flipped_image);
image=flipped_image;
}
}
/*
Proceed to next image.
*/
if (image_info->number_scenes != 0)
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
*magick='\0';
if (bmp_info.ba_offset != 0)
{
offset=SeekBlob(image,(MagickOffsetType) bmp_info.ba_offset,SEEK_SET);
if (offset < 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
}
count=ReadBlob(image,2,magick);
if ((count == 2) && (IsBMP(magick,2) != MagickFalse))
{
/*
Acquire next image structure.
*/
AcquireNextImage(image_info,image);
if (GetNextImageInList(image) == (Image *) NULL)
{
status=MagickFalse;
break;
}
image=SyncNextImageInList(image);
status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
GetBlobSize(image));
if (status == MagickFalse)
break;
}
} while (IsBMP(magick,2) != MagickFalse);
(void) CloseBlob(image);
if (status == MagickFalse)
return(DestroyImageList(image));
return(GetFirstImageInList(image));
}
| 1
|
432,244
|
void memory_listener_unregister(MemoryListener *listener)
{
if (!listener->address_space) {
return;
}
listener_del_address_space(listener, listener->address_space);
QTAILQ_REMOVE(&listener->address_space->uc->memory_listeners, listener, link);
QTAILQ_REMOVE(&listener->address_space->listeners, listener, link_as);
listener->address_space = NULL;
}
| 0
|
514,295
|
bool multi_update::send_eof()
{
char buff[STRING_BUFFER_USUAL_SIZE];
ulonglong id;
killed_state killed_status= NOT_KILLED;
DBUG_ENTER("multi_update::send_eof");
THD_STAGE_INFO(thd, stage_updating_reference_tables);
/*
Does updates for the last n - 1 tables, returns 0 if ok;
error takes into account killed status gained in do_updates()
*/
int local_error= thd->is_error();
if (likely(!local_error))
local_error = (table_count) ? do_updates() : 0;
/*
if local_error is not set ON until after do_updates() then
later carried out killing should not affect binlogging.
*/
killed_status= (local_error == 0) ? NOT_KILLED : thd->killed;
THD_STAGE_INFO(thd, stage_end);
/* We must invalidate the query cache before binlog writing and
ha_autocommit_... */
if (updated)
{
query_cache_invalidate3(thd, update_tables, 1);
}
/*
Write the SQL statement to the binlog if we updated
rows and we succeeded or if we updated some non
transactional tables.
The query has to binlog because there's a modified non-transactional table
either from the query's list or via a stored routine: bug#13270,23333
*/
if (thd->transaction.stmt.modified_non_trans_table)
thd->transaction.all.modified_non_trans_table= TRUE;
thd->transaction.all.m_unsafe_rollback_flags|=
(thd->transaction.stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT);
if (likely(local_error == 0 ||
thd->transaction.stmt.modified_non_trans_table))
{
if (WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open())
{
int errcode= 0;
if (likely(local_error == 0))
thd->clear_error();
else
errcode= query_error_code(thd, killed_status == NOT_KILLED);
bool force_stmt= false;
for (TABLE *table= all_tables->table; table; table= table->next)
{
if (table->versioned(VERS_TRX_ID))
{
force_stmt= true;
break;
}
}
enum_binlog_format save_binlog_format;
save_binlog_format= thd->get_current_stmt_binlog_format();
if (force_stmt)
thd->set_current_stmt_binlog_format_stmt();
if (thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(),
thd->query_length(), transactional_tables, FALSE,
FALSE, errcode) > 0)
local_error= 1; // Rollback update
thd->set_current_stmt_binlog_format(save_binlog_format);
}
}
DBUG_ASSERT(trans_safe || !updated ||
thd->transaction.stmt.modified_non_trans_table);
if (likely(local_error != 0))
error_handled= TRUE; // to force early leave from ::abort_result_set()
if (unlikely(local_error > 0)) // if the above log write did not fail ...
{
/* Safety: If we haven't got an error before (can happen in do_updates) */
my_message(ER_UNKNOWN_ERROR, "An error occurred in multi-table update",
MYF(0));
DBUG_RETURN(TRUE);
}
if (!thd->lex->analyze_stmt)
{
id= thd->arg_of_last_insert_id_function ?
thd->first_successful_insert_id_in_prev_stmt : 0;
my_snprintf(buff, sizeof(buff), ER_THD(thd, ER_UPDATE_INFO),
(ulong) found, (ulong) updated, (ulong) thd->cuted_fields);
::my_ok(thd, (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated,
id, buff);
}
DBUG_RETURN(FALSE);
}
| 0
|
353,171
|
SplashPath SplashOutputDev::convertPath(GfxState *state, GfxPath *path,
bool dropEmptySubpaths) {
SplashPath sPath;
GfxSubpath *subpath;
int n, i, j;
n = dropEmptySubpaths ? 1 : 0;
for (i = 0; i < path->getNumSubpaths(); ++i) {
subpath = path->getSubpath(i);
if (subpath->getNumPoints() > n) {
sPath.reserve(subpath->getNumPoints() + 1);
sPath.moveTo((SplashCoord)subpath->getX(0),
(SplashCoord)subpath->getY(0));
j = 1;
while (j < subpath->getNumPoints()) {
if (subpath->getCurve(j)) {
sPath.curveTo((SplashCoord)subpath->getX(j),
(SplashCoord)subpath->getY(j),
(SplashCoord)subpath->getX(j+1),
(SplashCoord)subpath->getY(j+1),
(SplashCoord)subpath->getX(j+2),
(SplashCoord)subpath->getY(j+2));
j += 3;
} else {
sPath.lineTo((SplashCoord)subpath->getX(j),
(SplashCoord)subpath->getY(j));
++j;
}
}
if (subpath->isClosed()) {
sPath.close();
}
}
}
return sPath;
}
| 0
|
416,363
|
f_getcmdscreenpos(typval_T *argvars UNUSED, typval_T *rettv)
{
cmdline_info_T *p = get_ccline_ptr();
rettv->vval.v_number = p != NULL ? p->cmdspos + 1 : 0;
}
| 0
|
459,152
|
static int tcf_block_insert(struct tcf_block *block, struct net *net,
struct netlink_ext_ack *extack)
{
struct tcf_net *tn = net_generic(net, tcf_net_id);
int err;
idr_preload(GFP_KERNEL);
spin_lock(&tn->idr_lock);
err = idr_alloc_u32(&tn->idr, block, &block->index, block->index,
GFP_NOWAIT);
spin_unlock(&tn->idr_lock);
idr_preload_end();
return err;
}
| 0
|
482,534
|
getNumber(widechar *string, widechar *number) {
/* Convert a string of wide character digits to an integer */
int k = 0;
*number = 0;
while (string[k] >= '0' && string[k] <= '9')
*number = 10 * *number + (string[k++] - '0');
return k;
}
| 0
|
402,659
|
set_up_outpe(context *ctx, int fd, Pe *inpe, Pe **outpe)
{
size_t size;
char *addr;
addr = pe_rawfile(inpe, &size);
off_t offset = lseek(fd, 0, SEEK_SET);
if (offset < 0) {
ctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,
"could not read output file: %m");
return -1;
}
int rc = ftruncate(fd, size);
if (rc < 0) {
ctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,
"could not extend output file: %m");
return -1;
}
rc = write(fd, addr, size);
if (rc < 0) {
ctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,
"could not write to output file: %m");
return -1;
}
*outpe = pe_begin(fd, PE_C_RDWR_MMAP, NULL);
if (!*outpe)
*outpe = pe_begin(fd, PE_C_RDWR, NULL);
if (!*outpe) {
ctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,
"could not set up output: %s",
pe_errmsg(pe_errno()));
return -1;
}
pe_clearcert(*outpe);
return 0;
}
| 0
|
381,853
|
void udf_evict_inode(struct inode *inode)
{
struct udf_inode_info *iinfo = UDF_I(inode);
int want_delete = 0;
if (!is_bad_inode(inode)) {
if (!inode->i_nlink) {
want_delete = 1;
udf_setsize(inode, 0);
udf_update_inode(inode, IS_SYNC(inode));
}
if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB &&
inode->i_size != iinfo->i_lenExtents) {
udf_warn(inode->i_sb,
"Inode %lu (mode %o) has inode size %llu different from extent length %llu. Filesystem need not be standards compliant.\n",
inode->i_ino, inode->i_mode,
(unsigned long long)inode->i_size,
(unsigned long long)iinfo->i_lenExtents);
}
}
truncate_inode_pages_final(&inode->i_data);
invalidate_inode_buffers(inode);
clear_inode(inode);
kfree(iinfo->i_data);
iinfo->i_data = NULL;
udf_clear_extent_cache(inode);
if (want_delete) {
udf_free_inode(inode);
}
}
| 0
|
299,908
|
retry_arg(uschar **paddr, int type)
{
uschar *p = *paddr;
uschar *pp;
if (*p++ != ',') log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "comma expected");
while (isspace(*p)) p++;
pp = p;
while (isalnum(*p) || (type == 1 && *p == '.')) p++;
if (*p != 0 && !isspace(*p) && *p != ',' && *p != ';')
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "comma or semicolon expected");
*paddr = p;
switch (type)
{
case 0:
return readconf_readtime(pp, *p, FALSE);
case 1:
return readconf_readfixed(pp, *p);
}
return 0; /* Keep picky compilers happy */
}
| 0
|
328,917
|
R_API char *r_bin_java_get_bin_obj_json(RBinJavaObj *bin) {
PJ *pj = pj_new ();
// this is a class dictionary
pj_o (pj);
// get the initial class dict data
r_bin_java_get_class_info_json (bin, pj);
// add named lists
r_bin_java_get_method_json_definitions (bin, pj);
r_bin_java_get_field_json_definitions (bin, pj);
r_bin_java_get_import_json_definitions (bin, pj);
//r_bin_java_get_interface_json_definitions (bin, pj);
pj_end (pj);
return pj_drain (pj);
}
| 0
|
272,351
|
PK11_DestroySlotListElement(PK11SlotList *slots, PK11SlotListElement **psle)
{
while (psle && *psle)
*psle = PK11_GetNextSafe(slots, *psle, PR_FALSE);
}
| 0
|
442,776
|
static int ftpcccmethod(struct Configurable *config, char *str)
{
if(curlx_strequal("passive", str))
return CURLFTPSSL_CCC_PASSIVE;
if(curlx_strequal("active", str))
return CURLFTPSSL_CCC_ACTIVE;
warnf(config, "unrecognized ftp CCC method '%s', using default\n", str);
return CURLFTPSSL_CCC_PASSIVE;
}
| 0
|
512,876
|
const double *const_ptr_double() const { return &value; }
| 0
|
486,818
|
static inline void rx_desc_set_eof(uint32_t *desc)
{
desc[1] |= DESC_1_RX_EOF;
}
| 0
|
238,489
|
static int grow_stack_state(struct bpf_func_state *state, int size)
{
size_t old_n = state->allocated_stack / BPF_REG_SIZE, n = size / BPF_REG_SIZE;
if (old_n >= n)
return 0;
state->stack = realloc_array(state->stack, old_n, n, sizeof(struct bpf_stack_state));
if (!state->stack)
return -ENOMEM;
state->allocated_stack = size;
return 0;
}
| 0
|
204,101
|
R_API RBinJavaAttrInfo *r_bin_java_constant_value_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {
ut64 offset = 6;
RBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);
if (attr) {
attr->type = R_BIN_JAVA_ATTR_TYPE_CONST_VALUE_ATTR;
attr->info.constant_value_attr.constantvalue_idx = R_BIN_JAVA_USHORT (buffer, offset);
offset += 2;
attr->size = offset;
}
// IFDBG r_bin_java_print_constant_value_attr_summary(attr);
return attr;
}
| 1
|
417,098
|
mp_sint32 PlayerGeneric::adjustFrequency(mp_uint32 frequency)
{
this->frequency = frequency;
mp_sint32 res = MP_OK;
if (mixer)
res = mixer->setSampleRate(frequency);
return res;
}
| 0
|
90,799
|
void QuotaManager::NotifyStorageModified(
QuotaClient::ID client_id,
const GURL& origin, StorageType type, int64 delta) {
NotifyStorageModifiedInternal(client_id, origin, type, delta,
base::Time::Now());
}
| 0
|
225,462
|
Status MutableGraphView::RemoveRegularFanin(absl::string_view node_name,
const TensorId& fanin) {
auto error_status = [node_name, fanin](absl::string_view msg) {
string params = absl::Substitute("node_name='$0', fanin='$1'", node_name,
fanin.ToString());
return MutationError("RemoveRegularFanin", params, msg);
};
TF_RETURN_IF_ERROR(CheckFaninIsRegular(fanin, error_status));
TF_RETURN_IF_ERROR(
CheckRemovingFaninFromSelf(node_name, fanin, error_status));
NodeDef* node = GetNode(node_name);
TF_RETURN_IF_ERROR(CheckNodeExists(node_name, node, error_status));
NodeDef* fanin_node = GetNode(fanin.node());
TF_RETURN_IF_ERROR(CheckNodeExists(fanin.node(), fanin_node, error_status));
RemoveRegularFaninInternal(node, {fanin_node, fanin.index()});
return Status::OK();
}
| 0
|
246,637
|
static u64 naludmx_next_start_code(GF_BitStream *bs, u64 offset, u64 fsize, u32 *sc_size)
{
u32 pos=0, nb_zeros=0;
while (offset+pos<fsize) {
u8 b = gf_bs_read_u8(bs);
pos++;
switch (b) {
case 1:
//break at first 0xXX000001 or 0x00000001
if (nb_zeros>=2) {
*sc_size = (nb_zeros==2) ? 3 : 4;
return offset+pos;
}
nb_zeros = 0;
break;
case 0:
nb_zeros++;
break;
default:
nb_zeros=0;
break;
}
}
//eof
return 0;
}
| 0
|
312,509
|
vgr_process_args(
exarg_T *eap,
vgr_args_T *args)
{
char_u *p;
vim_memset(args, 0, sizeof(*args));
args->regmatch.regprog = NULL;
args->qf_title = vim_strsave(qf_cmdtitle(*eap->cmdlinep));
if (eap->addr_count > 0)
args->tomatch = eap->line2;
else
args->tomatch = MAXLNUM;
// Get the search pattern: either white-separated or enclosed in //
p = skip_vimgrep_pat(eap->arg, &args->spat, &args->flags);
if (p == NULL)
{
emsg(_(e_invalid_search_pattern_or_delimiter));
return FAIL;
}
vgr_init_regmatch(&args->regmatch, args->spat);
if (args->regmatch.regprog == NULL)
return FAIL;
p = skipwhite(p);
if (*p == NUL)
{
emsg(_(e_file_name_missing_or_invalid_pattern));
return FAIL;
}
// Parse the list of arguments, wildcards have already been expanded.
if ((get_arglist_exp(p, &args->fcount, &args->fnames, TRUE) == FAIL) ||
args->fcount == 0)
{
emsg(_(e_no_match));
return FAIL;
}
return OK;
}
| 0
|
316,987
|
static int selinux_file_fcntl(struct file *file, unsigned int cmd,
unsigned long arg)
{
const struct cred *cred = current_cred();
int err = 0;
switch (cmd) {
case F_SETFL:
if ((file->f_flags & O_APPEND) && !(arg & O_APPEND)) {
err = file_has_perm(cred, file, FILE__WRITE);
break;
}
fallthrough;
case F_SETOWN:
case F_SETSIG:
case F_GETFL:
case F_GETOWN:
case F_GETSIG:
case F_GETOWNER_UIDS:
/* Just check FD__USE permission */
err = file_has_perm(cred, file, 0);
break;
case F_GETLK:
case F_SETLK:
case F_SETLKW:
case F_OFD_GETLK:
case F_OFD_SETLK:
case F_OFD_SETLKW:
#if BITS_PER_LONG == 32
case F_GETLK64:
case F_SETLK64:
case F_SETLKW64:
#endif
err = file_has_perm(cred, file, FILE__LOCK);
break;
}
return err;
}
| 0
|
265,444
|
static int sqfs_read_inode_table(unsigned char **inode_table)
{
struct squashfs_super_block *sblk = ctxt.sblk;
u64 start, n_blks, table_offset, table_size;
int j, ret = 0, metablks_count;
unsigned char *src_table, *itb;
u32 src_len, dest_offset = 0;
unsigned long dest_len = 0;
bool compressed;
table_size = get_unaligned_le64(&sblk->directory_table_start) -
get_unaligned_le64(&sblk->inode_table_start);
start = get_unaligned_le64(&sblk->inode_table_start) /
ctxt.cur_dev->blksz;
n_blks = sqfs_calc_n_blks(sblk->inode_table_start,
sblk->directory_table_start, &table_offset);
/* Allocate a proper sized buffer (itb) to store the inode table */
itb = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
if (!itb)
return -ENOMEM;
if (sqfs_disk_read(start, n_blks, itb) < 0) {
ret = -EINVAL;
goto free_itb;
}
/* Parse inode table (metadata block) header */
ret = sqfs_read_metablock(itb, table_offset, &compressed, &src_len);
if (ret) {
ret = -EINVAL;
goto free_itb;
}
/* Calculate size to store the whole decompressed table */
metablks_count = sqfs_count_metablks(itb, table_offset, table_size);
if (metablks_count < 1) {
ret = -EINVAL;
goto free_itb;
}
*inode_table = malloc(metablks_count * SQFS_METADATA_BLOCK_SIZE);
if (!*inode_table) {
ret = -ENOMEM;
printf("Error: failed to allocate squashfs inode_table of size %i, increasing CONFIG_SYS_MALLOC_LEN could help\n",
metablks_count * SQFS_METADATA_BLOCK_SIZE);
goto free_itb;
}
src_table = itb + table_offset + SQFS_HEADER_SIZE;
/* Extract compressed Inode table */
for (j = 0; j < metablks_count; j++) {
sqfs_read_metablock(itb, table_offset, &compressed, &src_len);
if (compressed) {
dest_len = SQFS_METADATA_BLOCK_SIZE;
ret = sqfs_decompress(&ctxt, *inode_table +
dest_offset, &dest_len,
src_table, src_len);
if (ret) {
free(*inode_table);
*inode_table = NULL;
goto free_itb;
}
dest_offset += dest_len;
} else {
memcpy(*inode_table + (j * SQFS_METADATA_BLOCK_SIZE),
src_table, src_len);
}
/*
* Offsets to the decompression destination, to the metadata
* buffer 'itb' and to the decompression source, respectively.
*/
table_offset += src_len + SQFS_HEADER_SIZE;
src_table += src_len + SQFS_HEADER_SIZE;
}
free_itb:
free(itb);
return ret;
}
| 0
|
314,481
|
static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
{
union kvm_mmu_page_role mmu_role = vcpu->arch.mmu->mmu_role.base;
int i;
bool host_writable;
gpa_t first_pte_gpa;
bool flush = false;
/*
* Ignore various flags when verifying that it's safe to sync a shadow
* page using the current MMU context.
*
* - level: not part of the overall MMU role and will never match as the MMU's
* level tracks the root level
* - access: updated based on the new guest PTE
* - quadrant: not part of the overall MMU role (similar to level)
*/
const union kvm_mmu_page_role sync_role_ign = {
.level = 0xf,
.access = 0x7,
.quadrant = 0x3,
};
/*
* Direct pages can never be unsync, and KVM should never attempt to
* sync a shadow page for a different MMU context, e.g. if the role
* differs then the memslot lookup (SMM vs. non-SMM) will be bogus, the
* reserved bits checks will be wrong, etc...
*/
if (WARN_ON_ONCE(sp->role.direct ||
(sp->role.word ^ mmu_role.word) & ~sync_role_ign.word))
return -1;
first_pte_gpa = FNAME(get_level1_sp_gpa)(sp);
for (i = 0; i < PT64_ENT_PER_PAGE; i++) {
u64 *sptep, spte;
struct kvm_memory_slot *slot;
unsigned pte_access;
pt_element_t gpte;
gpa_t pte_gpa;
gfn_t gfn;
if (!sp->spt[i])
continue;
pte_gpa = first_pte_gpa + i * sizeof(pt_element_t);
if (kvm_vcpu_read_guest_atomic(vcpu, pte_gpa, &gpte,
sizeof(pt_element_t)))
return -1;
if (FNAME(prefetch_invalid_gpte)(vcpu, sp, &sp->spt[i], gpte)) {
flush = true;
continue;
}
gfn = gpte_to_gfn(gpte);
pte_access = sp->role.access;
pte_access &= FNAME(gpte_access)(gpte);
FNAME(protect_clean_gpte)(vcpu->arch.mmu, &pte_access, gpte);
if (sync_mmio_spte(vcpu, &sp->spt[i], gfn, pte_access))
continue;
if (gfn != sp->gfns[i]) {
drop_spte(vcpu->kvm, &sp->spt[i]);
flush = true;
continue;
}
sptep = &sp->spt[i];
spte = *sptep;
host_writable = spte & shadow_host_writable_mask;
slot = kvm_vcpu_gfn_to_memslot(vcpu, gfn);
make_spte(vcpu, sp, slot, pte_access, gfn,
spte_to_pfn(spte), spte, true, false,
host_writable, &spte);
flush |= mmu_spte_update(sptep, spte);
}
return flush;
}
| 0
|
477,817
|
static void kvm_rtas_int_on(struct kvm_vcpu *vcpu, struct rtas_args *args)
{
u32 irq;
int rc;
if (be32_to_cpu(args->nargs) != 1 || be32_to_cpu(args->nret) != 1) {
rc = -3;
goto out;
}
irq = be32_to_cpu(args->args[0]);
if (xics_on_xive())
rc = kvmppc_xive_int_on(vcpu->kvm, irq);
else
rc = kvmppc_xics_int_on(vcpu->kvm, irq);
if (rc)
rc = -3;
out:
args->rets[0] = cpu_to_be32(rc);
}
| 0
|
509,521
|
static int maria_rollback(handlerton *hton, THD *thd, bool all)
{
TRN *trn= THD_TRN;
DBUG_ENTER("maria_rollback");
if (!trn)
DBUG_RETURN(0);
if (trn->undo_lsn)
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_DATA_WAS_COMMITED_UNDER_ROLLBACK,
ER_THD(thd, ER_DATA_WAS_COMMITED_UNDER_ROLLBACK),
"Aria");
if (all)
DBUG_RETURN(maria_commit(hton, thd, all));
/* Statement rollbacks are ignored. Commit will happen in external_lock */
DBUG_RETURN(0);
}
| 0
|
353,130
|
void SplashOutputDev::clearPatternOpacity(GfxState *state) {
splash->clearPatternAlpha();
}
| 0
|
90,134
|
virtual void EnableWifiNetworkDevice(bool enable) {
EnableNetworkDeviceType(TYPE_WIFI, enable);
}
| 0
|
225,040
|
conninfo_uri_parse_params(char *params,
PQconninfoOption *connOptions,
PQExpBuffer errorMessage)
{
while (*params)
{
char *keyword = params;
char *value = NULL;
char *p = params;
bool malloced = false;
int oldmsglen;
/*
* Scan the params string for '=' and '&', marking the end of keyword
* and value respectively.
*/
for (;;)
{
if (*p == '=')
{
/* Was there '=' already? */
if (value != NULL)
{
appendPQExpBuffer(errorMessage,
libpq_gettext("extra key/value separator \"=\" in URI query parameter: \"%s\"\n"),
keyword);
return false;
}
/* Cut off keyword, advance to value */
*p++ = '\0';
value = p;
}
else if (*p == '&' || *p == '\0')
{
/*
* If not at the end, cut off value and advance; leave p
* pointing to start of the next parameter, if any.
*/
if (*p != '\0')
*p++ = '\0';
/* Was there '=' at all? */
if (value == NULL)
{
appendPQExpBuffer(errorMessage,
libpq_gettext("missing key/value separator \"=\" in URI query parameter: \"%s\"\n"),
keyword);
return false;
}
/* Got keyword and value, go process them. */
break;
}
else
++p; /* Advance over all other bytes. */
}
keyword = conninfo_uri_decode(keyword, errorMessage);
if (keyword == NULL)
{
/* conninfo_uri_decode already set an error message */
return false;
}
value = conninfo_uri_decode(value, errorMessage);
if (value == NULL)
{
/* conninfo_uri_decode already set an error message */
free(keyword);
return false;
}
malloced = true;
/*
* Special keyword handling for improved JDBC compatibility.
*/
if (strcmp(keyword, "ssl") == 0 &&
strcmp(value, "true") == 0)
{
free(keyword);
free(value);
malloced = false;
keyword = "sslmode";
value = "require";
}
/*
* Store the value if the corresponding option exists; ignore
* otherwise. At this point both keyword and value are not
* URI-encoded.
*/
oldmsglen = errorMessage->len;
if (!conninfo_storeval(connOptions, keyword, value,
errorMessage, true, false))
{
/* Insert generic message if conninfo_storeval didn't give one. */
if (errorMessage->len == oldmsglen)
appendPQExpBuffer(errorMessage,
libpq_gettext("invalid URI query parameter: \"%s\"\n"),
keyword);
/* And fail. */
if (malloced)
{
free(keyword);
free(value);
}
return false;
}
if (malloced)
{
free(keyword);
free(value);
}
/* Proceed to next key=value pair, if any */
params = p;
}
return true;
}
| 0
|
412,145
|
dnscrypt_pad(uint8_t *buf, const size_t len, const size_t max_len,
const uint8_t *nonce, const uint8_t *secretkey)
{
uint8_t *buf_padding_area = buf + len;
size_t padded_len;
uint32_t rnd;
// no padding
if (max_len < len + DNSCRYPT_MIN_PAD_LEN)
return len;
assert(nonce[crypto_box_HALF_NONCEBYTES] == nonce[0]);
crypto_stream((unsigned char *)&rnd, (unsigned long long)sizeof(rnd), nonce,
secretkey);
padded_len =
len + DNSCRYPT_MIN_PAD_LEN + rnd % (max_len - len -
DNSCRYPT_MIN_PAD_LEN + 1);
padded_len += DNSCRYPT_BLOCK_SIZE - padded_len % DNSCRYPT_BLOCK_SIZE;
if (padded_len > max_len)
padded_len = max_len;
memset(buf_padding_area, 0, padded_len - len);
*buf_padding_area = 0x80;
return padded_len;
}
| 0
|
226,121
|
GF_Err tmin_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_TMINBox *ptr = (GF_TMINBox *)s;
ISOM_DECREASE_SIZE(ptr, 4)
ptr->minTime = gf_bs_read_u32(bs);
return GF_OK;
}
| 0
|
487,650
|
void emergency_restart(void)
{
machine_emergency_restart();
}
| 0
|
402,649
|
generate_empty_sequence(cms_context *cms, SECItem *encoded)
{
SECItem empty = {.type = SEC_ASN1_SEQUENCE,
.data = NULL,
.len = 0
};
void *ret;
ret = SEC_ASN1EncodeItem(cms->arena, encoded, &empty,
EmptySequenceTemplate);
if (ret == NULL)
cmsreterr(-1, cms, "could not encode empty sequence");
return 0;
}
| 0
|
387,597
|
static __poll_t snd_ctl_poll(struct file *file, poll_table * wait)
{
__poll_t mask;
struct snd_ctl_file *ctl;
ctl = file->private_data;
if (!ctl->subscribed)
return 0;
poll_wait(file, &ctl->change_sleep, wait);
mask = 0;
if (!list_empty(&ctl->events))
mask |= EPOLLIN | EPOLLRDNORM;
return mask;
}
| 0
|
473,975
|
init_property_list(void)
{
int r;
PROPERTY_LIST_ADD_PROP("hiragana", CR_Hiragana);
PROPERTY_LIST_ADD_PROP("katakana", CR_Katakana);
PropertyInited = 1;
end:
return r;
}
| 0
|
455,313
|
shell_glob_filename (pathname)
const char *pathname;
{
#if defined (USE_POSIX_GLOB_LIBRARY)
register int i;
char *temp, **results;
glob_t filenames;
int glob_flags;
temp = quote_string_for_globbing (pathname, QGLOB_FILENAME);
filenames.gl_offs = 0;
# if defined (GLOB_PERIOD)
glob_flags = glob_dot_filenames ? GLOB_PERIOD : 0;
# else
glob_flags = 0;
# endif /* !GLOB_PERIOD */
glob_flags |= (GLOB_ERR | GLOB_DOOFFS);
i = glob (temp, glob_flags, (posix_glob_errfunc_t *)NULL, &filenames);
free (temp);
if (i == GLOB_NOSPACE || i == GLOB_ABORTED)
return ((char **)NULL);
else if (i == GLOB_NOMATCH)
filenames.gl_pathv = (char **)NULL;
else if (i != 0) /* other error codes not in POSIX.2 */
filenames.gl_pathv = (char **)NULL;
results = filenames.gl_pathv;
if (results && ((GLOB_FAILED (results)) == 0))
{
if (should_ignore_glob_matches ())
ignore_glob_matches (results);
if (results && results[0])
strvec_sort (results);
else
{
FREE (results);
results = (char **)NULL;
}
}
return (results);
#else /* !USE_POSIX_GLOB_LIBRARY */
char *temp, **results;
int gflags, quoted_pattern;
noglob_dot_filenames = glob_dot_filenames == 0;
temp = quote_string_for_globbing (pathname, QGLOB_FILENAME);
quoted_pattern = STREQ (pathname, temp) == 0;
gflags = glob_star ? GX_GLOBSTAR : 0;
results = glob_filename (temp, gflags);
free (temp);
if (results && ((GLOB_FAILED (results)) == 0))
{
if (should_ignore_glob_matches ())
ignore_glob_matches (results);
if (results && results[0])
strvec_sort (results);
else
{
FREE (results);
results = (char **)&glob_error_return;
}
}
return (results);
#endif /* !USE_POSIX_GLOB_LIBRARY */
}
| 0
|
434,903
|
move_landscape_buffer(ht_landscape_info_t *ht_landscape, byte *contone_align,
int data_length)
{
int k;
int position_curr, position_new;
if (ht_landscape->index < 0) {
/* Moving right to left, move column to far right */
position_curr = ht_landscape->curr_pos + 1;
position_new = LAND_BITS-1;
} else {
/* Moving left to right, move column to far left */
position_curr = ht_landscape->curr_pos - 1;
position_new = 0;
}
if (position_curr != position_new) {
for (k = 0; k < data_length; k++) {
contone_align[position_new] = contone_align[position_curr];
position_curr += LAND_BITS;
position_new += LAND_BITS;
}
}
}
| 0
|
361,751
|
static int em28xx_hint_board(struct em28xx *dev)
{
int i;
if (dev->is_webcam) {
if (dev->em28xx_sensor == EM28XX_MT9V011) {
dev->model = EM2820_BOARD_SILVERCREST_WEBCAM;
} else if (dev->em28xx_sensor == EM28XX_MT9M001 ||
dev->em28xx_sensor == EM28XX_MT9M111) {
dev->model = EM2750_BOARD_UNKNOWN;
}
/* FIXME: IMPROVE ! */
return 0;
}
/*
* HINT method: EEPROM
*
* This method works only for boards with eeprom.
* Uses a hash of all eeprom bytes. The hash should be
* unique for a vendor/tuner pair.
* There are a high chance that tuners for different
* video standards produce different hashes.
*/
for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
if (dev->hash == em28xx_eeprom_hash[i].hash) {
dev->model = em28xx_eeprom_hash[i].model;
dev->tuner_type = em28xx_eeprom_hash[i].tuner;
dev_err(&dev->intf->dev,
"Your board has no unique USB ID.\n"
"A hint were successfully done, based on eeprom hash.\n"
"This method is not 100%% failproof.\n"
"If the board were misdetected, please email this log to:\n"
"\tV4L Mailing List <linux-media@vger.kernel.org>\n"
"Board detected as %s\n",
em28xx_boards[dev->model].name);
return 0;
}
}
/*
* HINT method: I2C attached devices
*
* This method works for all boards.
* Uses a hash of i2c scanned devices.
* Devices with the same i2c attached chips will
* be considered equal.
* This method is less precise than the eeprom one.
*/
/* user did not request i2c scanning => do it now */
if (!dev->i2c_hash)
em28xx_do_i2c_scan(dev, dev->def_i2c_bus);
for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
dev->model = em28xx_i2c_hash[i].model;
dev->tuner_type = em28xx_i2c_hash[i].tuner;
dev_err(&dev->intf->dev,
"Your board has no unique USB ID.\n"
"A hint were successfully done, based on i2c devicelist hash.\n"
"This method is not 100%% failproof.\n"
"If the board were misdetected, please email this log to:\n"
"\tV4L Mailing List <linux-media@vger.kernel.org>\n"
"Board detected as %s\n",
em28xx_boards[dev->model].name);
return 0;
}
}
dev_err(&dev->intf->dev,
"Your board has no unique USB ID and thus need a hint to be detected.\n"
"You may try to use card=<n> insmod option to workaround that.\n"
"Please send an email with this log to:\n"
"\tV4L Mailing List <linux-media@vger.kernel.org>\n"
"Board eeprom hash is 0x%08lx\n"
"Board i2c devicelist hash is 0x%08lx\n",
dev->hash, dev->i2c_hash);
dev_err(&dev->intf->dev,
"Here is a list of valid choices for the card=<n> insmod option:\n");
for (i = 0; i < em28xx_bcount; i++) {
dev_err(&dev->intf->dev,
" card=%d -> %s\n", i, em28xx_boards[i].name);
}
return -1;
}
| 0
|
401,597
|
static inline void timer_sync_wait_running(struct timer_base *base) { }
| 0
|
432,698
|
ModuleExport size_t RegisterWMFImage(void)
{
MagickInfo
*entry;
entry = AcquireMagickInfo("WMF","WMZ","Compressed Windows Meta File");
#if defined(MAGICKCORE_SANS_DELEGATE) || defined(MAGICKCORE_WMF_DELEGATE)
entry->decoder=ReadWMFImage;
#endif
entry->flags|=CoderDecoderSeekableStreamFlag;
(void) RegisterMagickInfo(entry);
entry=AcquireMagickInfo("WMF","WMF","Windows Meta File");
#if defined(MAGICKCORE_SANS_DELEGATE) || defined(MAGICKCORE_WMF_DELEGATE)
entry->decoder=ReadWMFImage;
#endif
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.