unique_id
int64 13
189k
| target
int64 0
1
| code
stringlengths 20
241k
| __index_level_0__
int64 0
18.9k
|
---|---|---|---|
24,121 | 0 | static int prism2_close(struct net_device *dev)
{
struct hostap_interface *iface;
local_info_t *local;
PDEBUG(DEBUG_FLOW, "%s: prism2_close\n", dev->name);
iface = netdev_priv(dev);
local = iface->local;
if (dev == local->ddev) {
prism2_sta_deauth(local, WLAN_REASON_DEAUTH_LEAVING);
}
#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
if (!local->hostapd && dev == local->dev &&
(!local->func->card_present || local->func->card_present(local)) &&
local->hw_ready && local->ap && local->iw_mode == IW_MODE_MASTER)
hostap_deauth_all_stas(dev, local->ap, 1);
#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
if (dev == local->dev) {
local->func->hw_shutdown(dev, HOSTAP_HW_ENABLE_CMDCOMPL);
}
if (netif_running(dev)) {
netif_stop_queue(dev);
netif_device_detach(dev);
}
cancel_work_sync(&local->reset_queue);
cancel_work_sync(&local->set_multicast_list_queue);
cancel_work_sync(&local->set_tim_queue);
#ifndef PRISM2_NO_STATION_MODES
cancel_work_sync(&local->info_queue);
#endif
cancel_work_sync(&local->comms_qual_update);
module_put(local->hw_module);
local->num_dev_open--;
if (dev != local->dev && local->dev->flags & IFF_UP &&
local->master_dev_auto_open && local->num_dev_open == 1) {
/* Close master radio interface automatically if it was also
* opened automatically and we are now closing the last
* remaining non-master device. */
dev_close(local->dev);
}
return 0;
}
| 400 |
145,145 | 0 | void GpuProcessHost::DidDestroyOffscreenContext(const GURL& url) {
auto candidate = urls_with_live_offscreen_contexts_.find(url);
if (candidate != urls_with_live_offscreen_contexts_.end()) {
urls_with_live_offscreen_contexts_.erase(candidate);
}
}
| 401 |
164,555 | 0 | int corruptPageError(int lineno, MemPage *p){
char *zMsg;
sqlite3BeginBenignMalloc();
zMsg = sqlite3_mprintf("database corruption page %d of %s",
(int)p->pgno, sqlite3PagerFilename(p->pBt->pPager, 0)
);
sqlite3EndBenignMalloc();
if( zMsg ){
sqlite3ReportError(SQLITE_CORRUPT, lineno, zMsg);
}
sqlite3_free(zMsg);
return SQLITE_CORRUPT_BKPT;
}
| 402 |
108,285 | 0 | bool FrameLoader::subframeIsLoading() const
{
for (Frame* child = m_frame->tree()->lastChild(); child; child = child->tree()->previousSibling()) {
FrameLoader* childLoader = child->loader();
DocumentLoader* documentLoader = childLoader->documentLoader();
if (documentLoader && documentLoader->isLoadingInAPISense())
return true;
documentLoader = childLoader->provisionalDocumentLoader();
if (documentLoader && documentLoader->isLoadingInAPISense())
return true;
documentLoader = childLoader->policyDocumentLoader();
if (documentLoader)
return true;
}
return false;
}
| 403 |
134,936 | 0 | bool IsVoiceInteractionEnabled() {
return IsVoiceInteractionLocalesSupported() &&
IsVoiceInteractionFlagsEnabled();
}
| 404 |
128,720 | 0 | std::string TemplateURLRef::ReplaceSearchTerms(
const SearchTermsArgs& search_terms_args,
const SearchTermsData& search_terms_data,
PostContent* post_content) const {
ParseIfNecessary(search_terms_data);
if (!valid_)
return std::string();
std::string url(HandleReplacements(search_terms_args, search_terms_data,
post_content));
GURL gurl(url);
if (!gurl.is_valid())
return url;
std::vector<std::string> query_params;
if (search_terms_args.append_extra_query_params) {
std::string extra_params(
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kExtraSearchQueryParams));
if (!extra_params.empty())
query_params.push_back(extra_params);
}
if (!search_terms_args.suggest_query_params.empty())
query_params.push_back(search_terms_args.suggest_query_params);
if (!gurl.query().empty())
query_params.push_back(gurl.query());
if (query_params.empty())
return url;
GURL::Replacements replacements;
std::string query_str = base::JoinString(query_params, "&");
replacements.SetQueryStr(query_str);
return gurl.ReplaceComponents(replacements).possibly_invalid_spec();
}
| 405 |
107,141 | 0 | void LayerTreeHostQt::renderNextFrame()
{
m_waitingForUIProcess = false;
scheduleLayerFlush();
}
| 406 |
164,867 | 0 | bool VerifyNoDownloads() const {
DownloadManager::DownloadVector items;
GetDownloads(browser(), &items);
return items.empty();
}
| 407 |
24,685 | 0 | void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec *itp)
{
union cpu_time_count now;
struct task_struct *p = timer->it.cpu.task;
int clear_dead;
/*
* Easy part: convert the reload time.
*/
sample_to_timespec(timer->it_clock,
timer->it.cpu.incr, &itp->it_interval);
if (timer->it.cpu.expires.sched == 0) { /* Timer not armed at all. */
itp->it_value.tv_sec = itp->it_value.tv_nsec = 0;
return;
}
if (unlikely(p == NULL)) {
/*
* This task already died and the timer will never fire.
* In this case, expires is actually the dead value.
*/
dead:
sample_to_timespec(timer->it_clock, timer->it.cpu.expires,
&itp->it_value);
return;
}
/*
* Sample the clock to take the difference with the expiry time.
*/
if (CPUCLOCK_PERTHREAD(timer->it_clock)) {
cpu_clock_sample(timer->it_clock, p, &now);
clear_dead = p->exit_state;
} else {
read_lock(&tasklist_lock);
if (unlikely(p->signal == NULL)) {
/*
* The process has been reaped.
* We can't even collect a sample any more.
* Call the timer disarmed, nothing else to do.
*/
put_task_struct(p);
timer->it.cpu.task = NULL;
timer->it.cpu.expires.sched = 0;
read_unlock(&tasklist_lock);
goto dead;
} else {
cpu_clock_sample_group(timer->it_clock, p, &now);
clear_dead = (unlikely(p->exit_state) &&
thread_group_empty(p));
}
read_unlock(&tasklist_lock);
}
if ((timer->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE) {
if (timer->it.cpu.incr.sched == 0 &&
cpu_time_before(timer->it_clock,
timer->it.cpu.expires, now)) {
/*
* Do-nothing timer expired and has no reload,
* so it's as if it was never set.
*/
timer->it.cpu.expires.sched = 0;
itp->it_value.tv_sec = itp->it_value.tv_nsec = 0;
return;
}
/*
* Account for any expirations and reloads that should
* have happened.
*/
bump_cpu_timer(timer, now);
}
if (unlikely(clear_dead)) {
/*
* We've noticed that the thread is dead, but
* not yet reaped. Take this opportunity to
* drop our task ref.
*/
clear_dead_task(timer, now);
goto dead;
}
if (cpu_time_before(timer->it_clock, now, timer->it.cpu.expires)) {
sample_to_timespec(timer->it_clock,
cpu_time_sub(timer->it_clock,
timer->it.cpu.expires, now),
&itp->it_value);
} else {
/*
* The timer should have expired already, but the firing
* hasn't taken place yet. Say it's just about to expire.
*/
itp->it_value.tv_nsec = 1;
itp->it_value.tv_sec = 0;
}
}
| 408 |
18,596 | 0 | long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
{
struct inode *inode = file->f_path.dentry->d_inode;
handle_t *handle;
loff_t new_size;
unsigned int max_blocks;
int ret = 0;
int ret2 = 0;
int retries = 0;
int flags;
struct ext4_map_blocks map;
unsigned int credits, blkbits = inode->i_blkbits;
/*
* currently supporting (pre)allocate mode for extent-based
* files _only_
*/
if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
return -EOPNOTSUPP;
/* Return error if mode is not supported */
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
return -EOPNOTSUPP;
if (mode & FALLOC_FL_PUNCH_HOLE)
return ext4_punch_hole(file, offset, len);
trace_ext4_fallocate_enter(inode, offset, len, mode);
map.m_lblk = offset >> blkbits;
/*
* We can't just convert len to max_blocks because
* If blocksize = 4096 offset = 3072 and len = 2048
*/
max_blocks = (EXT4_BLOCK_ALIGN(len + offset, blkbits) >> blkbits)
- map.m_lblk;
/*
* credits to insert 1 extent into extent tree
*/
credits = ext4_chunk_trans_blocks(inode, max_blocks);
mutex_lock(&inode->i_mutex);
ret = inode_newsize_ok(inode, (len + offset));
if (ret) {
mutex_unlock(&inode->i_mutex);
trace_ext4_fallocate_exit(inode, offset, max_blocks, ret);
return ret;
}
flags = EXT4_GET_BLOCKS_CREATE_UNINIT_EXT;
if (mode & FALLOC_FL_KEEP_SIZE)
flags |= EXT4_GET_BLOCKS_KEEP_SIZE;
/*
* Don't normalize the request if it can fit in one extent so
* that it doesn't get unnecessarily split into multiple
* extents.
*/
if (len <= EXT_UNINIT_MAX_LEN << blkbits)
flags |= EXT4_GET_BLOCKS_NO_NORMALIZE;
/* Prevent race condition between unwritten */
ext4_flush_unwritten_io(inode);
retry:
while (ret >= 0 && ret < max_blocks) {
map.m_lblk = map.m_lblk + ret;
map.m_len = max_blocks = max_blocks - ret;
handle = ext4_journal_start(inode, credits);
if (IS_ERR(handle)) {
ret = PTR_ERR(handle);
break;
}
ret = ext4_map_blocks(handle, inode, &map, flags);
if (ret <= 0) {
#ifdef EXT4FS_DEBUG
WARN_ON(ret <= 0);
printk(KERN_ERR "%s: ext4_ext_map_blocks "
"returned error inode#%lu, block=%u, "
"max_blocks=%u", __func__,
inode->i_ino, map.m_lblk, max_blocks);
#endif
ext4_mark_inode_dirty(handle, inode);
ret2 = ext4_journal_stop(handle);
break;
}
if ((map.m_lblk + ret) >= (EXT4_BLOCK_ALIGN(offset + len,
blkbits) >> blkbits))
new_size = offset + len;
else
new_size = ((loff_t) map.m_lblk + ret) << blkbits;
ext4_falloc_update_inode(inode, mode, new_size,
(map.m_flags & EXT4_MAP_NEW));
ext4_mark_inode_dirty(handle, inode);
if ((file->f_flags & O_SYNC) && ret >= max_blocks)
ext4_handle_sync(handle);
ret2 = ext4_journal_stop(handle);
if (ret2)
break;
}
if (ret == -ENOSPC &&
ext4_should_retry_alloc(inode->i_sb, &retries)) {
ret = 0;
goto retry;
}
mutex_unlock(&inode->i_mutex);
trace_ext4_fallocate_exit(inode, offset, max_blocks,
ret > 0 ? ret2 : ret);
return ret > 0 ? ret2 : ret;
}
| 409 |
183,593 | 1 | WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient(
unsigned long resource_id, const GURL& url, bool notify_needed,
intptr_t notify_data, intptr_t existing_stream) {
// Stream already exists. This typically happens for range requests
// initiated via NPN_RequestRead.
if (existing_stream) {
NPAPI::PluginStream* plugin_stream =
reinterpret_cast<NPAPI::PluginStream*>(existing_stream);
return plugin_stream->AsResourceClient();
}
std::string mime_type;
NPAPI::PluginStreamUrl *stream = instance()->CreateStream(
resource_id, url, mime_type, notify_needed,
reinterpret_cast<void*>(notify_data));
return stream;
}
| 410 |
87,482 | 0 | static unsigned generateFixedLitLenTree(HuffmanTree* tree)
{
unsigned i, error = 0;
unsigned* bitlen = (unsigned*)calloc(NUM_DEFLATE_CODE_SYMBOLS, sizeof(unsigned));
if(!bitlen) return 83; /*alloc fail*/
/*288 possible codes: 0-255=literals, 256=endcode, 257-285=lengthcodes, 286-287=unused*/
for(i = 0; i <= 143; i++) bitlen[i] = 8;
for(i = 144; i <= 255; i++) bitlen[i] = 9;
for(i = 256; i <= 279; i++) bitlen[i] = 7;
for(i = 280; i <= 287; i++) bitlen[i] = 8;
error = HuffmanTree_makeFromLengths(tree, bitlen, NUM_DEFLATE_CODE_SYMBOLS, 15);
free(bitlen);
return error;
}
| 411 |
82,318 | 0 | NO_INLINE JsVar *jspeBlockOrStatement() {
if (lex->tk=='{') {
jspeBlock();
return 0;
} else {
JsVar *v = jspeStatement();
if (lex->tk==';') JSP_ASSERT_MATCH(';');
return v;
}
}
/** Parse using current lexer until we hit the end of
* input or there was some problem. */
NO_INLINE JsVar *jspParse() {
JsVar *v = 0;
while (!JSP_SHOULDNT_PARSE && lex->tk != LEX_EOF) {
jsvUnLock(v);
v = jspeBlockOrStatement();
}
return v;
}
NO_INLINE JsVar *jspeStatementVar() {
JsVar *lastDefined = 0;
/* variable creation. TODO - we need a better way of parsing the left
* hand side. Maybe just have a flag called can_create_var that we
* set and then we parse as if we're doing a normal equals.*/
assert(lex->tk==LEX_R_VAR || lex->tk==LEX_R_LET || lex->tk==LEX_R_CONST);
jslGetNextToken();
bool hasComma = true; // for first time in loop
while (hasComma && lex->tk == LEX_ID && !jspIsInterrupted()) {
JsVar *a = 0;
if (JSP_SHOULD_EXECUTE) {
a = jspeiFindOnTop(jslGetTokenValueAsString(lex), true);
if (!a) { // out of memory
jspSetError(false);
return lastDefined;
}
}
JSP_MATCH_WITH_CLEANUP_AND_RETURN(LEX_ID, jsvUnLock(a), lastDefined);
if (lex->tk == '=') {
JsVar *var;
JSP_MATCH_WITH_CLEANUP_AND_RETURN('=', jsvUnLock(a), lastDefined);
var = jsvSkipNameAndUnLock(jspeAssignmentExpression());
if (JSP_SHOULD_EXECUTE)
jspReplaceWith(a, var);
jsvUnLock(var);
}
jsvUnLock(lastDefined);
lastDefined = a;
hasComma = lex->tk == ',';
if (hasComma) JSP_MATCH_WITH_RETURN(',', lastDefined);
}
return lastDefined;
}
NO_INLINE JsVar *jspeStatementIf() {
bool cond;
JsVar *var, *result = 0;
JSP_ASSERT_MATCH(LEX_R_IF);
JSP_MATCH('(');
var = jspeExpression();
if (JSP_SHOULDNT_PARSE) return var;
JSP_MATCH(')');
cond = JSP_SHOULD_EXECUTE && jsvGetBoolAndUnLock(jsvSkipName(var));
jsvUnLock(var);
JSP_SAVE_EXECUTE();
if (!cond) jspSetNoExecute();
JsVar *a = jspeBlockOrStatement();
if (!cond) {
jsvUnLock(a);
JSP_RESTORE_EXECUTE();
} else {
result = a;
}
if (lex->tk==LEX_R_ELSE) {
JSP_ASSERT_MATCH(LEX_R_ELSE);
JSP_SAVE_EXECUTE();
if (cond) jspSetNoExecute();
JsVar *a = jspeBlockOrStatement();
if (cond) {
jsvUnLock(a);
JSP_RESTORE_EXECUTE();
} else {
result = a;
}
}
return result;
}
NO_INLINE JsVar *jspeStatementSwitch() {
JSP_ASSERT_MATCH(LEX_R_SWITCH);
JSP_MATCH('(');
JsVar *switchOn = jspeExpression();
JSP_SAVE_EXECUTE();
bool execute = JSP_SHOULD_EXECUTE;
JSP_MATCH_WITH_CLEANUP_AND_RETURN(')', jsvUnLock(switchOn), 0);
if (!execute) { jsvUnLock(switchOn); jspeBlock(); return 0; }
JSP_MATCH_WITH_CLEANUP_AND_RETURN('{', jsvUnLock(switchOn), 0);
bool executeDefault = true;
if (execute) execInfo.execute=EXEC_NO|EXEC_IN_SWITCH;
while (lex->tk==LEX_R_CASE) {
JSP_MATCH_WITH_CLEANUP_AND_RETURN(LEX_R_CASE, jsvUnLock(switchOn), 0);
JsExecFlags oldFlags = execInfo.execute;
if (execute) execInfo.execute=EXEC_YES|EXEC_IN_SWITCH;
JsVar *test = jspeAssignmentExpression();
execInfo.execute = oldFlags|EXEC_IN_SWITCH;;
JSP_MATCH_WITH_CLEANUP_AND_RETURN(':', jsvUnLock2(switchOn, test), 0);
bool cond = false;
if (execute)
cond = jsvGetBoolAndUnLock(jsvMathsOpSkipNames(switchOn, test, LEX_TYPEEQUAL));
if (cond) executeDefault = false;
jsvUnLock(test);
if (cond && (execInfo.execute&EXEC_RUN_MASK)==EXEC_NO)
execInfo.execute=EXEC_YES|EXEC_IN_SWITCH;
while (!JSP_SHOULDNT_PARSE && lex->tk!=LEX_EOF && lex->tk!=LEX_R_CASE && lex->tk!=LEX_R_DEFAULT && lex->tk!='}')
jsvUnLock(jspeBlockOrStatement());
oldExecute |= execInfo.execute & (EXEC_ERROR_MASK|EXEC_RETURN); // copy across any errors/exceptions/returns
}
jsvUnLock(switchOn);
if (execute && (execInfo.execute&EXEC_RUN_MASK)==EXEC_BREAK) {
execInfo.execute=EXEC_YES|EXEC_IN_SWITCH;
} else {
executeDefault = true;
}
JSP_RESTORE_EXECUTE();
if (lex->tk==LEX_R_DEFAULT) {
JSP_ASSERT_MATCH(LEX_R_DEFAULT);
JSP_MATCH(':');
JSP_SAVE_EXECUTE();
if (!executeDefault) jspSetNoExecute();
else execInfo.execute |= EXEC_IN_SWITCH;
while (!JSP_SHOULDNT_PARSE && lex->tk!=LEX_EOF && lex->tk!='}')
jsvUnLock(jspeBlockOrStatement());
oldExecute |= execInfo.execute & (EXEC_ERROR_MASK|EXEC_RETURN); // copy across any errors/exceptions/returns
execInfo.execute = execInfo.execute & (JsExecFlags)~EXEC_BREAK;
JSP_RESTORE_EXECUTE();
}
JSP_MATCH('}');
| 412 |
25,181 | 0 | static inline int rt_is_expired(struct rtable *rth)
{
return rth->rt_genid != rt_genid(dev_net(rth->dst.dev));
}
| 413 |
124,048 | 0 | bool BookmarksGetFunction::RunImpl() {
scoped_ptr<bookmarks::GetRecent::Params> params(
bookmarks::GetRecent::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
if (params->number_of_items < 1)
return false;
std::vector<const BookmarkNode*> nodes;
bookmark_utils::GetMostRecentlyAddedEntries(
BookmarkModelFactory::GetForProfile(profile()),
params->number_of_items,
&nodes);
std::vector<linked_ptr<BookmarkTreeNode> > tree_nodes;
std::vector<const BookmarkNode*>::iterator i = nodes.begin();
for (; i != nodes.end(); ++i) {
const BookmarkNode* node = *i;
bookmark_api_helpers::AddNode(node, &tree_nodes, false);
}
results_ = bookmarks::GetRecent::Results::Create(tree_nodes);
return true;
}
| 414 |
139,098 | 0 | void CreateUnifiedStream(const url::Origin& security_origin) {
std::string output_id = GetNondefaultIdExpectedToPassPermissionsCheck();
std::string input_id = GetNondefaultInputId();
std::string hashed_output_id = MediaStreamManager::GetHMACForMediaDeviceID(
kSalt, url::Origin(GURL(kSecurityOrigin)), output_id);
audio_manager_->CreateDeviceAssociation(input_id, output_id);
int session_id = media_stream_manager_->audio_input_device_manager()->Open(
StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "Fake input device",
input_id));
base::RunLoop().RunUntilIdle();
media::AudioParameters params(
media::AudioParameters::AUDIO_FAKE, media::CHANNEL_LAYOUT_STEREO,
media::AudioParameters::kAudioCDSampleRate, 16,
media::AudioParameters::kAudioCDSampleRate / 10);
EXPECT_CALL(*host_.get(),
OnDeviceAuthorized(kStreamId, media::OUTPUT_DEVICE_STATUS_OK, _,
hashed_output_id))
.Times(1);
EXPECT_CALL(*host_.get(), WasNotifiedOfCreation(kStreamId, _));
EXPECT_CALL(mirroring_manager_, AddDiverter(render_process_host_.GetID(),
kRenderFrameId, NotNull()))
.RetiresOnSaturation();
EXPECT_CALL(mirroring_manager_, RemoveDiverter(NotNull()))
.RetiresOnSaturation();
host_->OnRequestDeviceAuthorization(kStreamId, kRenderFrameId, session_id,
/*device id*/ std::string(),
security_origin);
auth_run_loop_.Run();
host_->OnCreateStream(kStreamId, kRenderFrameId, params);
SyncWithAudioThread();
}
| 415 |
7,100 | 0 | tt_cmap14_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
FT_UNUSED( cmap );
/* This can't happen */
*pchar_code = 0;
return 0;
}
| 416 |
27,935 | 0 | static int orinoco_ioctl_set_mlme(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
struct orinoco_private *priv = ndev_priv(dev);
struct iw_mlme *mlme = (struct iw_mlme *)extra;
unsigned long flags;
int ret = 0;
if (orinoco_lock(priv, &flags) != 0)
return -EBUSY;
switch (mlme->cmd) {
case IW_MLME_DEAUTH:
/* silently ignore */
break;
case IW_MLME_DISASSOC:
ret = orinoco_hw_disassociate(priv, mlme->addr.sa_data,
mlme->reason_code);
break;
default:
ret = -EOPNOTSUPP;
}
orinoco_unlock(priv, &flags);
return ret;
}
| 417 |
161,034 | 0 | TopDomainEntry IDNSpoofChecker::LookupSkeletonInTopDomains(
const std::string& skeleton) {
DCHECK(!skeleton.empty());
TopDomainPreloadDecoder preload_decoder(
g_trie_params.huffman_tree, g_trie_params.huffman_tree_size,
g_trie_params.trie, g_trie_params.trie_bits,
g_trie_params.trie_root_position);
auto labels = base::SplitStringPiece(skeleton, ".", base::KEEP_WHITESPACE,
base::SPLIT_WANT_ALL);
if (labels.size() > kNumberOfLabelsToCheck) {
labels.erase(labels.begin(),
labels.begin() + labels.size() - kNumberOfLabelsToCheck);
}
while (labels.size() > 1) {
std::string partial_skeleton = base::JoinString(labels, ".");
bool match = false;
bool decoded = preload_decoder.Decode(partial_skeleton, &match);
DCHECK(decoded);
if (!decoded)
return TopDomainEntry();
if (match)
return preload_decoder.matching_top_domain();
labels.erase(labels.begin());
}
return TopDomainEntry();
}
| 418 |
18,241 | 0 | conn *conn_from_freelist() {
conn *c;
pthread_mutex_lock(&conn_lock);
if (freecurr > 0) {
c = freeconns[--freecurr];
} else {
c = NULL;
}
pthread_mutex_unlock(&conn_lock);
return c;
}
| 419 |
53,565 | 0 | read_Digests(struct archive_read *a, struct _7z_digests *d, size_t num)
{
const unsigned char *p;
unsigned i;
if (num == 0)
return (-1);
memset(d, 0, sizeof(*d));
d->defineds = malloc(num);
if (d->defineds == NULL)
return (-1);
/*
* Read Bools.
*/
if ((p = header_bytes(a, 1)) == NULL)
return (-1);
if (*p == 0) {
if (read_Bools(a, d->defineds, num) < 0)
return (-1);
} else
/* All are defined */
memset(d->defineds, 1, num);
d->digests = calloc(num, sizeof(*d->digests));
if (d->digests == NULL)
return (-1);
for (i = 0; i < num; i++) {
if (d->defineds[i]) {
if ((p = header_bytes(a, 4)) == NULL)
return (-1);
d->digests[i] = archive_le32dec(p);
}
}
return (0);
}
| 420 |
176,374 | 0 | static void TransitionElementsKindImpl(Handle<JSObject> object,
Handle<Map> to_map) {
Handle<Map> from_map = handle(object->map());
ElementsKind from_kind = from_map->elements_kind();
ElementsKind to_kind = to_map->elements_kind();
if (IsFastHoleyElementsKind(from_kind)) {
to_kind = GetHoleyElementsKind(to_kind);
}
if (from_kind != to_kind) {
DCHECK(IsFastElementsKind(from_kind));
DCHECK(IsFastElementsKind(to_kind));
DCHECK_NE(TERMINAL_FAST_ELEMENTS_KIND, from_kind);
Handle<FixedArrayBase> from_elements(object->elements());
if (object->elements() == object->GetHeap()->empty_fixed_array() ||
IsFastDoubleElementsKind(from_kind) ==
IsFastDoubleElementsKind(to_kind)) {
JSObject::MigrateToMap(object, to_map);
} else {
DCHECK((IsFastSmiElementsKind(from_kind) &&
IsFastDoubleElementsKind(to_kind)) ||
(IsFastDoubleElementsKind(from_kind) &&
IsFastObjectElementsKind(to_kind)));
uint32_t capacity = static_cast<uint32_t>(object->elements()->length());
Handle<FixedArrayBase> elements = ConvertElementsWithCapacity(
object, from_elements, from_kind, capacity);
JSObject::SetMapAndElements(object, to_map, elements);
}
if (FLAG_trace_elements_transitions) {
JSObject::PrintElementsTransition(stdout, object, from_kind,
from_elements, to_kind,
handle(object->elements()));
}
}
}
| 421 |
131,829 | 0 | static void unsignedLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
TestObjectPythonV8Internal::unsignedLongAttributeAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
| 422 |
133,681 | 0 | string cookie_value() {
return decoder_->cookie_value_;
}
| 423 |
113,734 | 0 | GpuProcessHostUIShim::~GpuProcessHostUIShim() {
DCHECK(CalledOnValidThread());
g_hosts_by_id.Pointer()->Remove(host_id_);
DictionaryValue* dict = new DictionaryValue();
dict->SetInteger("level", logging::LOG_ERROR);
dict->SetString("header", "GpuProcessHostUIShim");
dict->SetString("message", "GPU Process Crashed.");
GpuDataManagerImpl::GetInstance()->AddLogMessage(dict);
}
| 424 |
44,425 | 0 | static bool perms_include(int fmode, mode_t req_mode)
{
mode_t r;
switch (req_mode & O_ACCMODE) {
case O_RDONLY:
r = S_IROTH;
break;
case O_WRONLY:
r = S_IWOTH;
break;
case O_RDWR:
r = S_IROTH | S_IWOTH;
break;
default:
return false;
}
return ((fmode & r) == r);
}
| 425 |
130,378 | 0 | HTMLFormControlElement::~HTMLFormControlElement()
{
#if !ENABLE(OILPAN)
#if ENABLE(ASSERT)
setNeedsWillValidateCheck();
setNeedsValidityCheck();
#endif
setForm(0);
#endif
}
| 426 |
32,752 | 0 | static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause)
{
struct tg3 *tp = netdev_priv(dev);
int err = 0;
if (tg3_flag(tp, USE_PHYLIB)) {
u32 newadv;
struct phy_device *phydev;
phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
if (!(phydev->supported & SUPPORTED_Pause) ||
(!(phydev->supported & SUPPORTED_Asym_Pause) &&
(epause->rx_pause != epause->tx_pause)))
return -EINVAL;
tp->link_config.flowctrl = 0;
if (epause->rx_pause) {
tp->link_config.flowctrl |= FLOW_CTRL_RX;
if (epause->tx_pause) {
tp->link_config.flowctrl |= FLOW_CTRL_TX;
newadv = ADVERTISED_Pause;
} else
newadv = ADVERTISED_Pause |
ADVERTISED_Asym_Pause;
} else if (epause->tx_pause) {
tp->link_config.flowctrl |= FLOW_CTRL_TX;
newadv = ADVERTISED_Asym_Pause;
} else
newadv = 0;
if (epause->autoneg)
tg3_flag_set(tp, PAUSE_AUTONEG);
else
tg3_flag_clear(tp, PAUSE_AUTONEG);
if (tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) {
u32 oldadv = phydev->advertising &
(ADVERTISED_Pause | ADVERTISED_Asym_Pause);
if (oldadv != newadv) {
phydev->advertising &=
~(ADVERTISED_Pause |
ADVERTISED_Asym_Pause);
phydev->advertising |= newadv;
if (phydev->autoneg) {
/*
* Always renegotiate the link to
* inform our link partner of our
* flow control settings, even if the
* flow control is forced. Let
* tg3_adjust_link() do the final
* flow control setup.
*/
return phy_start_aneg(phydev);
}
}
if (!epause->autoneg)
tg3_setup_flow_control(tp, 0, 0);
} else {
tp->link_config.advertising &=
~(ADVERTISED_Pause |
ADVERTISED_Asym_Pause);
tp->link_config.advertising |= newadv;
}
} else {
int irq_sync = 0;
if (netif_running(dev)) {
tg3_netif_stop(tp);
irq_sync = 1;
}
tg3_full_lock(tp, irq_sync);
if (epause->autoneg)
tg3_flag_set(tp, PAUSE_AUTONEG);
else
tg3_flag_clear(tp, PAUSE_AUTONEG);
if (epause->rx_pause)
tp->link_config.flowctrl |= FLOW_CTRL_RX;
else
tp->link_config.flowctrl &= ~FLOW_CTRL_RX;
if (epause->tx_pause)
tp->link_config.flowctrl |= FLOW_CTRL_TX;
else
tp->link_config.flowctrl &= ~FLOW_CTRL_TX;
if (netif_running(dev)) {
tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
err = tg3_restart_hw(tp, 1);
if (!err)
tg3_netif_start(tp);
}
tg3_full_unlock(tp);
}
return err;
}
| 427 |
17,266 | 0 | tt_cmap13_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
TT_CMap13 cmap13 = (TT_CMap13)cmap;
FT_UInt gindex;
/* no need to search */
if ( cmap13->valid && cmap13->cur_charcode == *pchar_code )
{
tt_cmap13_next( cmap13 );
if ( cmap13->valid )
{
gindex = cmap13->cur_gindex;
*pchar_code = cmap13->cur_charcode;
}
else
gindex = 0;
}
else
gindex = tt_cmap13_char_map_binary( cmap, pchar_code, 1 );
return gindex;
}
| 428 |
20,712 | 0 | void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu, struct kvm_async_pf *work)
{
int r;
if ((vcpu->arch.mmu.direct_map != work->arch.direct_map) ||
is_error_page(work->page))
return;
r = kvm_mmu_reload(vcpu);
if (unlikely(r))
return;
if (!vcpu->arch.mmu.direct_map &&
work->arch.cr3 != vcpu->arch.mmu.get_cr3(vcpu))
return;
vcpu->arch.mmu.page_fault(vcpu, work->gva, 0, true);
}
| 429 |
3,643 | 0 | static void print_word(BIO *bp, BN_ULONG w)
{
#ifdef SIXTY_FOUR_BIT
if (sizeof(w) > sizeof(unsigned long)) {
unsigned long h = (unsigned long)(w >> 32), l = (unsigned long)(w);
if (h)
BIO_printf(bp, "%lX%08lX", h, l);
else
BIO_printf(bp, "%lX", l);
return;
}
#endif
BIO_printf(bp, BN_HEX_FMT1, w);
}
| 430 |
160,148 | 0 | void BackendIO::OnIOComplete(int result) {
DCHECK(IsEntryOperation());
DCHECK_NE(result, net::ERR_IO_PENDING);
result_ = result;
NotifyController();
}
| 431 |
65,318 | 0 | nfsd4_clone(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
struct nfsd4_clone *clone)
{
struct file *src, *dst;
__be32 status;
status = nfsd4_verify_copy(rqstp, cstate, &clone->cl_src_stateid, &src,
&clone->cl_dst_stateid, &dst);
if (status)
goto out;
status = nfsd4_clone_file_range(src, clone->cl_src_pos,
dst, clone->cl_dst_pos, clone->cl_count);
fput(dst);
fput(src);
out:
return status;
}
| 432 |
154,531 | 0 | GLES2DecoderPassthroughImpl::TexturePendingBinding::TexturePendingBinding(
GLenum target,
GLuint unit,
base::WeakPtr<TexturePassthrough> texture)
: target(target), unit(unit), texture(std::move(texture)) {}
| 433 |
112,099 | 0 | const char* PassphraseRequiredReasonToString(
PassphraseRequiredReason reason) {
switch (reason) {
case REASON_PASSPHRASE_NOT_REQUIRED:
return "REASON_PASSPHRASE_NOT_REQUIRED";
case REASON_ENCRYPTION:
return "REASON_ENCRYPTION";
case REASON_DECRYPTION:
return "REASON_DECRYPTION";
default:
NOTREACHED();
return "INVALID_REASON";
}
}
| 434 |
93,259 | 0 | static inline u16 tun16_to_cpu(struct tun_struct *tun, __virtio16 val)
{
return __virtio16_to_cpu(tun_is_little_endian(tun), val);
}
| 435 |
142,763 | 0 | void HTMLMediaElement::ConfigureTextTrackDisplay() {
DCHECK(text_tracks_);
BLINK_MEDIA_LOG << "configureTextTrackDisplay(" << (void*)this << ")";
if (processing_preference_change_)
return;
bool have_visible_text_track = text_tracks_->HasShowingTracks();
text_tracks_visible_ = have_visible_text_track;
if (!have_visible_text_track && !GetMediaControls())
return;
GetCueTimeline().UpdateActiveCues(currentTime());
UpdateTextTrackDisplay();
}
| 436 |
3,033 | 0 | static int checkMatrixLMN(i_ctx_t * i_ctx_p, ref *CIEdict)
{
int code;
float value[9];
ref *tempref;
code = dict_find_string(CIEdict, "MatrixLMN", &tempref);
if (code > 0 && !r_has_type(tempref, t_null)) {
if (!r_is_array(tempref))
return_error(gs_error_typecheck);
if (r_size(tempref) != 9)
return_error(gs_error_rangecheck);
code = get_cie_param_array(imemory, tempref, 9, value);
if (code < 0)
return code;
}
return 0;
}
| 437 |
168,200 | 0 | void WebBluetoothServiceImpl::GattCharacteristicValueChanged(
device::BluetoothAdapter* adapter,
device::BluetoothRemoteGattCharacteristic* characteristic,
const std::vector<uint8_t>& value) {
if (!base::ContainsKey(characteristic_id_to_service_id_,
characteristic->GetIdentifier())) {
return;
}
if (!base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(
&WebBluetoothServiceImpl::NotifyCharacteristicValueChanged,
weak_ptr_factory_.GetWeakPtr(), characteristic->GetIdentifier(),
value))) {
LOG(WARNING) << "No TaskRunner.";
}
}
| 438 |
59,472 | 0 | xmlParseDocTypeDecl(xmlParserCtxtPtr ctxt) {
const xmlChar *name = NULL;
xmlChar *ExternalID = NULL;
xmlChar *URI = NULL;
/*
* We know that '<!DOCTYPE' has been detected.
*/
SKIP(9);
SKIP_BLANKS;
/*
* Parse the DOCTYPE name.
*/
name = xmlParseName(ctxt);
if (name == NULL) {
xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
"xmlParseDocTypeDecl : no DOCTYPE name !\n");
}
ctxt->intSubName = name;
SKIP_BLANKS;
/*
* Check for SystemID and ExternalID
*/
URI = xmlParseExternalID(ctxt, &ExternalID, 1);
if ((URI != NULL) || (ExternalID != NULL)) {
ctxt->hasExternalSubset = 1;
}
ctxt->extSubURI = URI;
ctxt->extSubSystem = ExternalID;
SKIP_BLANKS;
/*
* Create and update the internal subset.
*/
if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) &&
(!ctxt->disableSAX))
ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI);
if (ctxt->instate == XML_PARSER_EOF)
return;
/*
* Is there any internal subset declarations ?
* they are handled separately in xmlParseInternalSubset()
*/
if (RAW == '[')
return;
/*
* We should be at the end of the DOCTYPE declaration.
*/
if (RAW != '>') {
xmlFatalErr(ctxt, XML_ERR_DOCTYPE_NOT_FINISHED, NULL);
}
NEXT;
}
| 439 |
109,250 | 0 | void InspectorOverlay::reset(const IntSize& viewportSize, const IntSize& frameViewFullSize, int scrollX, int scrollY)
{
RefPtr<JSONObject> resetData = JSONObject::create();
resetData->setNumber("pageScaleFactor", m_page->pageScaleFactor());
resetData->setNumber("deviceScaleFactor", m_page->deviceScaleFactor());
resetData->setObject("viewportSize", buildObjectForSize(viewportSize));
resetData->setObject("frameViewFullSize", buildObjectForSize(frameViewFullSize));
resetData->setNumber("pageZoomFactor", m_page->mainFrame()->pageZoomFactor());
resetData->setNumber("scrollX", scrollX);
resetData->setNumber("scrollY", scrollY);
evaluateInOverlay("reset", resetData.release());
}
| 440 |
66,462 | 0 | static void cp2112_remove(struct hid_device *hdev)
{
struct cp2112_device *dev = hid_get_drvdata(hdev);
int i;
sysfs_remove_group(&hdev->dev.kobj, &cp2112_attr_group);
i2c_del_adapter(&dev->adap);
if (dev->gpio_poll) {
dev->gpio_poll = false;
cancel_delayed_work_sync(&dev->gpio_poll_worker);
}
for (i = 0; i < ARRAY_SIZE(dev->desc); i++) {
gpiochip_unlock_as_irq(&dev->gc, i);
gpiochip_free_own_desc(dev->desc[i]);
}
gpiochip_remove(&dev->gc);
/* i2c_del_adapter has finished removing all i2c devices from our
* adapter. Well behaved devices should no longer call our cp2112_xfer
* and should have waited for any pending calls to finish. It has also
* waited for device_unregister(&adap->dev) to complete. Therefore we
* can safely free our struct cp2112_device.
*/
hid_hw_close(hdev);
hid_hw_stop(hdev);
}
| 441 |
185,352 | 1 | void GLSurfaceOzoneSurfacelessSurfaceImpl::Destroy() {
if (!context_)
return;
scoped_refptr<gfx::GLContext> previous_context = gfx::GLContext::GetCurrent();
scoped_refptr<gfx::GLSurface> previous_surface;
bool was_current = previous_context && previous_context->IsCurrent(nullptr) &&
gfx::GLSurface::GetCurrent() == this;
if (!was_current) {
// Only take a reference to previous surface if it's not |this|
// because otherwise we can take a self reference from our own dtor.
previous_surface = gfx::GLSurface::GetCurrent();
context_->MakeCurrent(this);
}
glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
if (fbo_) {
glDeleteTextures(arraysize(textures_), textures_);
for (auto& texture : textures_)
texture = 0;
glDeleteFramebuffersEXT(1, &fbo_);
fbo_ = 0;
}
for (auto image : images_) {
if (image)
image->Destroy(true);
}
if (!was_current) {
previous_context->MakeCurrent(previous_surface.get());
} else {
context_->ReleaseCurrent(this);
}
}
| 442 |
85,839 | 0 | static void __dm_internal_suspend(struct mapped_device *md, unsigned suspend_flags)
{
struct dm_table *map = NULL;
lockdep_assert_held(&md->suspend_lock);
if (md->internal_suspend_count++)
return; /* nested internal suspend */
if (dm_suspended_md(md)) {
set_bit(DMF_SUSPENDED_INTERNALLY, &md->flags);
return; /* nest suspend */
}
map = rcu_dereference_protected(md->map, lockdep_is_held(&md->suspend_lock));
/*
* Using TASK_UNINTERRUPTIBLE because only NOFLUSH internal suspend is
* supported. Properly supporting a TASK_INTERRUPTIBLE internal suspend
* would require changing .presuspend to return an error -- avoid this
* until there is a need for more elaborate variants of internal suspend.
*/
(void) __dm_suspend(md, map, suspend_flags, TASK_UNINTERRUPTIBLE,
DMF_SUSPENDED_INTERNALLY);
dm_table_postsuspend_targets(map);
}
| 443 |
82,941 | 0 | static RList* relocs(RBinFile *bf) {
RList *ret = NULL;
RBinReloc *ptr = NULL;
RBinElfReloc *relocs = NULL;
struct Elf_(r_bin_elf_obj_t) *bin = NULL;
ut64 got_addr;
int i;
if (!bf || !bf->o || !bf->o->bin_obj) {
return NULL;
}
bin = bf->o->bin_obj;
if (!(ret = r_list_newf (free))) {
return NULL;
}
/* FIXME: This is a _temporary_ fix/workaround to prevent a use-after-
* free detected by ASan that would corrupt the relocation names */
r_list_free (imports (bf));
if ((got_addr = Elf_(r_bin_elf_get_section_addr) (bin, ".got")) == -1) {
got_addr = Elf_(r_bin_elf_get_section_addr) (bin, ".got.plt");
if (got_addr == -1) {
got_addr = 0;
}
}
if (got_addr < 1 && bin->ehdr.e_type == ET_REL) {
got_addr = Elf_(r_bin_elf_get_section_addr) (bin, ".got.r2");
if (got_addr == -1) {
got_addr = 0;
}
}
if (bf->o) {
if (!(relocs = Elf_(r_bin_elf_get_relocs) (bin))) {
return ret;
}
for (i = 0; !relocs[i].last; i++) {
if (!(ptr = reloc_convert (bin, &relocs[i], got_addr))) {
continue;
}
r_list_append (ret, ptr);
}
free (relocs);
}
return ret;
}
| 444 |
141,787 | 0 | std::string ChromeMetricsServiceClient::GetVersionString() {
return metrics::GetVersionString();
}
| 445 |
2,436 | 0 | bool smb2cli_conn_req_possible(struct smbXcli_conn *conn, uint32_t *max_dyn_len)
{
uint16_t credits = 1;
if (conn->smb2.cur_credits == 0) {
if (max_dyn_len != NULL) {
*max_dyn_len = 0;
}
return false;
}
if (conn->smb2.server.capabilities & SMB2_CAP_LARGE_MTU) {
credits = conn->smb2.cur_credits;
}
if (max_dyn_len != NULL) {
*max_dyn_len = credits * 65536;
}
return true;
}
| 446 |
160,517 | 0 | bool WebContentsImpl::OnMessageReceived(RenderFrameHostImpl* render_frame_host,
const IPC::Message& message) {
{
WebUIImpl* web_ui = render_frame_host->web_ui();
if (web_ui && web_ui->OnMessageReceived(message, render_frame_host))
return true;
}
for (auto& observer : observers_) {
if (observer.OnMessageReceived(message, render_frame_host))
return true;
}
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContentsImpl, message, render_frame_host)
IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse,
OnDomOperationResponse)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor,
OnThemeColorChanged)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad,
OnDocumentLoadedInFrame)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidLoadResourceFromMemoryCache,
OnDidLoadResourceFromMemoryCache)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayInsecureContent,
OnDidDisplayInsecureContent)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidContainInsecureFormAction,
OnDidContainInsecureFormAction)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunInsecureContent,
OnDidRunInsecureContent)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayContentWithCertificateErrors,
OnDidDisplayContentWithCertificateErrors)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunContentWithCertificateErrors,
OnDidRunContentWithCertificateErrors)
IPC_MESSAGE_HANDLER(FrameHostMsg_RegisterProtocolHandler,
OnRegisterProtocolHandler)
IPC_MESSAGE_HANDLER(FrameHostMsg_UnregisterProtocolHandler,
OnUnregisterProtocolHandler)
IPC_MESSAGE_HANDLER(FrameHostMsg_UpdatePageImportanceSignals,
OnUpdatePageImportanceSignals)
IPC_MESSAGE_HANDLER(FrameHostMsg_Find_Reply, OnFindReply)
IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
#if BUILDFLAG(ENABLE_PLUGINS)
IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceCreated,
OnPepperInstanceCreated)
IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted,
OnPepperInstanceDeleted)
IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung)
IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStartsPlayback,
OnPepperStartsPlayback)
IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStopsPlayback,
OnPepperStopsPlayback)
IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed)
IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach,
OnBrowserPluginMessage(render_frame_host,
message))
#endif
#if defined(OS_ANDROID)
IPC_MESSAGE_HANDLER(FrameHostMsg_FindMatchRects_Reply,
OnFindMatchRectsReply)
IPC_MESSAGE_HANDLER(FrameHostMsg_GetNearestFindResult_Reply,
OnGetNearestFindResultReply)
#endif
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
| 447 |
132,140 | 0 | ContentClient* RenderViewTest::CreateContentClient() {
return new TestContentClient;
}
| 448 |
180,301 | 1 | void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
{
int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;
int wid;
int w, wstart;
int thick = im->thick;
if (color == gdAntiAliased) {
/*
gdAntiAliased passed as color: use the much faster, much cheaper
and equally attractive gdImageAALine implementation. That
clips too, so don't clip twice.
*/
gdImageAALine(im, x1, y1, x2, y2, im->AA_color);
return;
}
/* 2.0.10: Nick Atty: clip to edges of drawing rectangle, return if no points need to be drawn */
if (!clip_1d(&x1,&y1,&x2,&y2,gdImageSX(im)) || !clip_1d(&y1,&x1,&y2,&x2,gdImageSY(im))) {
return;
}
dx = abs (x2 - x1);
dy = abs (y2 - y1);
if (dx == 0) {
gdImageVLine(im, x1, y1, y2, color);
return;
} else if (dy == 0) {
gdImageHLine(im, y1, x1, x2, color);
return;
}
if (dy <= dx) {
/* More-or-less horizontal. use wid for vertical stroke */
/* Doug Claar: watch out for NaN in atan2 (2.0.5) */
if ((dx == 0) && (dy == 0)) {
wid = 1;
} else {
/* 2.0.12: Michael Schwartz: divide rather than multiply;
TBB: but watch out for /0! */
double ac = cos (atan2 (dy, dx));
if (ac != 0) {
wid = thick / ac;
} else {
wid = 1;
}
if (wid == 0) {
wid = 1;
}
}
d = 2 * dy - dx;
incr1 = 2 * dy;
incr2 = 2 * (dy - dx);
if (x1 > x2) {
x = x2;
y = y2;
ydirflag = (-1);
xend = x1;
} else {
x = x1;
y = y1;
ydirflag = 1;
xend = x2;
}
/* Set up line thickness */
wstart = y - wid / 2;
for (w = wstart; w < wstart + wid; w++) {
gdImageSetPixel(im, x, w, color);
}
if (((y2 - y1) * ydirflag) > 0) {
while (x < xend) {
x++;
if (d < 0) {
d += incr1;
} else {
y++;
d += incr2;
}
wstart = y - wid / 2;
for (w = wstart; w < wstart + wid; w++) {
gdImageSetPixel (im, x, w, color);
}
}
} else {
while (x < xend) {
x++;
if (d < 0) {
d += incr1;
} else {
y--;
d += incr2;
}
wstart = y - wid / 2;
for (w = wstart; w < wstart + wid; w++) {
gdImageSetPixel (im, x, w, color);
}
}
}
} else {
/* More-or-less vertical. use wid for horizontal stroke */
/* 2.0.12: Michael Schwartz: divide rather than multiply;
TBB: but watch out for /0! */
double as = sin (atan2 (dy, dx));
if (as != 0) {
wid = thick / as;
} else {
wid = 1;
}
if (wid == 0) {
wid = 1;
}
d = 2 * dx - dy;
incr1 = 2 * dx;
incr2 = 2 * (dx - dy);
if (y1 > y2) {
y = y2;
x = x2;
yend = y1;
xdirflag = (-1);
} else {
y = y1;
x = x1;
yend = y2;
xdirflag = 1;
}
/* Set up line thickness */
wstart = x - wid / 2;
for (w = wstart; w < wstart + wid; w++) {
gdImageSetPixel (im, w, y, color);
}
if (((x2 - x1) * xdirflag) > 0) {
while (y < yend) {
y++;
if (d < 0) {
d += incr1;
} else {
x++;
d += incr2;
}
wstart = x - wid / 2;
for (w = wstart; w < wstart + wid; w++) {
gdImageSetPixel (im, w, y, color);
}
}
} else {
while (y < yend) {
y++;
if (d < 0) {
d += incr1;
} else {
x--;
d += incr2;
}
wstart = x - wid / 2;
for (w = wstart; w < wstart + wid; w++) {
gdImageSetPixel (im, w, y, color);
}
}
}
}
}
| 449 |
151,066 | 0 | bool FindInspectedBrowserAndTabIndex(
WebContents* inspected_web_contents, Browser** browser, int* tab) {
if (!inspected_web_contents)
return false;
for (auto* b : *BrowserList::GetInstance()) {
int tab_index =
b->tab_strip_model()->GetIndexOfWebContents(inspected_web_contents);
if (tab_index != TabStripModel::kNoTab) {
*browser = b;
*tab = tab_index;
return true;
}
}
return false;
}
| 450 |
77,939 | 0 | DestroyJNG(unsigned char *chunk,Image **color_image,
ImageInfo **color_image_info,Image **alpha_image,ImageInfo **alpha_image_info)
{
(void) RelinquishMagickMemory(chunk);
if (color_image_info && *color_image_info)
{
DestroyImageInfo(*color_image_info);
*color_image_info = (ImageInfo *)NULL;
}
if (alpha_image_info && *alpha_image_info)
{
DestroyImageInfo(*alpha_image_info);
*alpha_image_info = (ImageInfo *)NULL;
}
if (color_image && *color_image)
{
DestroyImage(*color_image);
*color_image = (Image *)NULL;
}
if (alpha_image && *alpha_image)
{
DestroyImage(*alpha_image);
*alpha_image = (Image *)NULL;
}
}
| 451 |
11,544 | 0 | bool ignore_file(const char *filename) {
assert(filename);
return
filename[0] == '.' ||
streq(filename, "lost+found") ||
streq(filename, "aquota.user") ||
streq(filename, "aquota.group") ||
endswith(filename, "~") ||
endswith(filename, ".rpmnew") ||
endswith(filename, ".rpmsave") ||
endswith(filename, ".rpmorig") ||
endswith(filename, ".dpkg-old") ||
endswith(filename, ".dpkg-new") ||
endswith(filename, ".swp");
}
| 452 |
76,147 | 0 | alloc_value_block(void (*alloc_func) (vector_t *), const char *block_type)
{
char *buf;
char *str = NULL;
vector_t *vec = NULL;
bool first_line = true;
buf = (char *) MALLOC(MAXBUF);
while (read_line(buf, MAXBUF)) {
if (!(vec = alloc_strvec(buf)))
continue;
if (first_line) {
first_line = false;
if (!strcmp(vector_slot(vec, 0), BOB)) {
free_strvec(vec);
continue;
}
log_message(LOG_INFO, "'%s' missing from beginning of block %s", BOB, block_type);
}
str = vector_slot(vec, 0);
if (!strcmp(str, EOB)) {
free_strvec(vec);
break;
}
if (vector_size(vec))
(*alloc_func) (vec);
free_strvec(vec);
}
FREE(buf);
}
| 453 |
68,007 | 0 | static MagickBooleanType load_tile_rle(Image *image,Image *tile_image,
XCFDocInfo *inDocInfo,XCFLayerInfo *inLayerInfo,size_t data_length)
{
ExceptionInfo
*exception;
MagickOffsetType
size;
Quantum
alpha;
register PixelPacket
*q;
size_t
length;
ssize_t
bytes_per_pixel,
count,
i,
j;
unsigned char
data,
pixel,
*xcfdata,
*xcfodata,
*xcfdatalimit;
bytes_per_pixel=(ssize_t) inDocInfo->bytes_per_pixel;
xcfdata=(unsigned char *) AcquireQuantumMemory(data_length,sizeof(*xcfdata));
if (xcfdata == (unsigned char *) NULL)
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
xcfodata=xcfdata;
count=ReadBlob(image, (size_t) data_length, xcfdata);
xcfdatalimit = xcfodata+count-1;
exception=(&image->exception);
alpha=ScaleCharToQuantum((unsigned char) inLayerInfo->alpha);
for (i=0; i < (ssize_t) bytes_per_pixel; i++)
{
q=GetAuthenticPixels(tile_image,0,0,tile_image->columns,tile_image->rows,
exception);
if (q == (PixelPacket *) NULL)
continue;
size=(MagickOffsetType) tile_image->rows*tile_image->columns;
while (size > 0)
{
if (xcfdata > xcfdatalimit)
goto bogus_rle;
pixel=(*xcfdata++);
length=(size_t) pixel;
if (length >= 128)
{
length=255-(length-1);
if (length == 128)
{
if (xcfdata >= xcfdatalimit)
goto bogus_rle;
length=(size_t) ((*xcfdata << 8) + xcfdata[1]);
xcfdata+=2;
}
size-=length;
if (size < 0)
goto bogus_rle;
if (&xcfdata[length-1] > xcfdatalimit)
goto bogus_rle;
while (length-- > 0)
{
data=(*xcfdata++);
switch (i)
{
case 0:
{
SetPixelRed(q,ScaleCharToQuantum(data));
if (inDocInfo->image_type == GIMP_GRAY)
{
SetPixelGreen(q,ScaleCharToQuantum(data));
SetPixelBlue(q,ScaleCharToQuantum(data));
}
else
{
SetPixelGreen(q,GetPixelRed(q));
SetPixelBlue(q,GetPixelRed(q));
}
SetPixelAlpha(q,alpha);
break;
}
case 1:
{
if (inDocInfo->image_type == GIMP_GRAY)
SetPixelAlpha(q,ScaleCharToQuantum(data));
else
SetPixelGreen(q,ScaleCharToQuantum(data));
break;
}
case 2:
{
SetPixelBlue(q,ScaleCharToQuantum(data));
break;
}
case 3:
{
SetPixelAlpha(q,ScaleCharToQuantum(data));
break;
}
}
q++;
}
}
else
{
length+=1;
if (length == 128)
{
if (xcfdata >= xcfdatalimit)
goto bogus_rle;
length=(size_t) ((*xcfdata << 8) + xcfdata[1]);
xcfdata+=2;
}
size-=length;
if (size < 0)
goto bogus_rle;
if (xcfdata > xcfdatalimit)
goto bogus_rle;
pixel=(*xcfdata++);
for (j=0; j < (ssize_t) length; j++)
{
data=pixel;
switch (i)
{
case 0:
{
SetPixelRed(q,ScaleCharToQuantum(data));
if (inDocInfo->image_type == GIMP_GRAY)
{
SetPixelGreen(q,ScaleCharToQuantum(data));
SetPixelBlue(q,ScaleCharToQuantum(data));
}
else
{
SetPixelGreen(q,GetPixelRed(q));
SetPixelBlue(q,GetPixelRed(q));
}
SetPixelAlpha(q,alpha);
break;
}
case 1:
{
if (inDocInfo->image_type == GIMP_GRAY)
SetPixelAlpha(q,ScaleCharToQuantum(data));
else
SetPixelGreen(q,ScaleCharToQuantum(data));
break;
}
case 2:
{
SetPixelBlue(q,ScaleCharToQuantum(data));
break;
}
case 3:
{
SetPixelAlpha(q,ScaleCharToQuantum(data));
break;
}
}
q++;
}
}
}
if (SyncAuthenticPixels(tile_image,exception) == MagickFalse)
break;
}
xcfodata=(unsigned char *) RelinquishMagickMemory(xcfodata);
return(MagickTrue);
bogus_rle:
if (xcfodata != (unsigned char *) NULL)
xcfodata=(unsigned char *) RelinquishMagickMemory(xcfodata);
return(MagickFalse);
}
| 454 |
19,643 | 0 | GC_INNER void * GC_generic_malloc_inner(size_t lb, int k)
{
void *op;
if(SMALL_OBJ(lb)) {
struct obj_kind * kind = GC_obj_kinds + k;
size_t lg = GC_size_map[lb];
void ** opp = &(kind -> ok_freelist[lg]);
op = *opp;
if (EXPECT(0 == op, FALSE)) {
if (GC_size_map[lb] == 0) {
if (!EXPECT(GC_is_initialized, TRUE)) GC_init();
if (GC_size_map[lb] == 0) GC_extend_size_map(lb);
return(GC_generic_malloc_inner(lb, k));
}
if (kind -> ok_reclaim_list == 0) {
if (!GC_alloc_reclaim_list(kind)) goto out;
}
op = GC_allocobj(lg, k);
if (op == 0) goto out;
}
*opp = obj_link(op);
obj_link(op) = 0;
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
} else {
op = (ptr_t)GC_alloc_large_and_clear(ADD_SLOP(lb), k, 0);
GC_bytes_allocd += lb;
}
out:
return op;
}
| 455 |
22,239 | 0 | struct net_device *rose_dev_get(rose_address *addr)
{
struct net_device *dev;
rcu_read_lock();
for_each_netdev_rcu(&init_net, dev) {
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0) {
dev_hold(dev);
goto out;
}
}
dev = NULL;
out:
rcu_read_unlock();
return dev;
}
| 456 |
32,300 | 0 | static struct ext4_dir_entry_tail *get_dirent_tail(struct inode *inode,
struct ext4_dir_entry *de)
{
struct ext4_dir_entry_tail *t;
#ifdef PARANOID
struct ext4_dir_entry *d, *top;
d = de;
top = (struct ext4_dir_entry *)(((void *)de) +
(EXT4_BLOCK_SIZE(inode->i_sb) -
sizeof(struct ext4_dir_entry_tail)));
while (d < top && d->rec_len)
d = (struct ext4_dir_entry *)(((void *)d) +
le16_to_cpu(d->rec_len));
if (d != top)
return NULL;
t = (struct ext4_dir_entry_tail *)d;
#else
t = EXT4_DIRENT_TAIL(de, EXT4_BLOCK_SIZE(inode->i_sb));
#endif
if (t->det_reserved_zero1 ||
le16_to_cpu(t->det_rec_len) != sizeof(struct ext4_dir_entry_tail) ||
t->det_reserved_zero2 ||
t->det_reserved_ft != EXT4_FT_DIR_CSUM)
return NULL;
return t;
}
| 457 |
185,538 | 1 | void XSSAuditor::init(Document* document, XSSAuditorDelegate* auditorDelegate)
{
const size_t miniumLengthForSuffixTree = 512; // FIXME: Tune this parameter.
const int suffixTreeDepth = 5;
ASSERT(isMainThread());
if (m_state != Uninitialized)
return;
m_state = FilteringTokens;
if (Settings* settings = document->settings())
m_isEnabled = settings->xssAuditorEnabled();
if (!m_isEnabled)
return;
m_documentURL = document->url().copy();
// In theory, the Document could have detached from the Frame after the
// XSSAuditor was constructed.
if (!document->frame()) {
m_isEnabled = false;
return;
}
if (m_documentURL.isEmpty()) {
// The URL can be empty when opening a new browser window or calling window.open("").
m_isEnabled = false;
return;
}
if (m_documentURL.protocolIsData()) {
m_isEnabled = false;
return;
}
if (document->encoding().isValid())
m_encoding = document->encoding();
m_decodedURL = fullyDecodeString(m_documentURL.string(), m_encoding);
if (m_decodedURL.find(isRequiredForInjection) == kNotFound)
m_decodedURL = String();
String httpBodyAsString;
if (DocumentLoader* documentLoader = document->frame()->loader().documentLoader()) {
DEFINE_STATIC_LOCAL(const AtomicString, XSSProtectionHeader, ("X-XSS-Protection", AtomicString::ConstructFromLiteral));
const AtomicString& headerValue = documentLoader->response().httpHeaderField(XSSProtectionHeader);
String errorDetails;
unsigned errorPosition = 0;
String reportURL;
KURL xssProtectionReportURL;
// Process the X-XSS-Protection header, then mix in the CSP header's value.
ReflectedXSSDisposition xssProtectionHeader = parseXSSProtectionHeader(headerValue, errorDetails, errorPosition, reportURL);
m_didSendValidXSSProtectionHeader = xssProtectionHeader != ReflectedXSSUnset && xssProtectionHeader != ReflectedXSSInvalid;
if ((xssProtectionHeader == FilterReflectedXSS || xssProtectionHeader == BlockReflectedXSS) && !reportURL.isEmpty()) {
xssProtectionReportURL = document->completeURL(reportURL);
if (MixedContentChecker::isMixedContent(document->securityOrigin(), xssProtectionReportURL)) {
errorDetails = "insecure reporting URL for secure page";
xssProtectionHeader = ReflectedXSSInvalid;
xssProtectionReportURL = KURL();
}
}
if (xssProtectionHeader == ReflectedXSSInvalid)
document->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Error parsing header X-XSS-Protection: " + headerValue + ": " + errorDetails + " at character position " + String::format("%u", errorPosition) + ". The default protections will be applied.");
ReflectedXSSDisposition cspHeader = document->contentSecurityPolicy()->reflectedXSSDisposition();
m_didSendValidCSPHeader = cspHeader != ReflectedXSSUnset && cspHeader != ReflectedXSSInvalid;
m_xssProtection = combineXSSProtectionHeaderAndCSP(xssProtectionHeader, cspHeader);
// FIXME: Combine the two report URLs in some reasonable way.
if (auditorDelegate)
auditorDelegate->setReportURL(xssProtectionReportURL.copy());
FormData* httpBody = documentLoader->originalRequest().httpBody();
if (httpBody && !httpBody->isEmpty()) {
httpBodyAsString = httpBody->flattenToString();
if (!httpBodyAsString.isEmpty()) {
m_decodedHTTPBody = fullyDecodeString(httpBodyAsString, m_encoding);
if (m_decodedHTTPBody.find(isRequiredForInjection) == kNotFound)
m_decodedHTTPBody = String();
if (m_decodedHTTPBody.length() >= miniumLengthForSuffixTree)
m_decodedHTTPBodySuffixTree = adoptPtr(new SuffixTree<ASCIICodebook>(m_decodedHTTPBody, suffixTreeDepth));
}
}
}
if (m_decodedURL.isEmpty() && m_decodedHTTPBody.isEmpty()) {
m_isEnabled = false;
return;
}
}
| 458 |
24,532 | 0 | static int b43_dma_set_mask(struct b43_wldev *dev, u64 mask)
{
u64 orig_mask = mask;
bool fallback = 0;
int err;
/* Try to set the DMA mask. If it fails, try falling back to a
* lower mask, as we can always also support a lower one. */
while (1) {
err = dma_set_mask(dev->dev->dma_dev, mask);
if (!err) {
err = dma_set_coherent_mask(dev->dev->dma_dev, mask);
if (!err)
break;
}
if (mask == DMA_BIT_MASK(64)) {
mask = DMA_BIT_MASK(32);
fallback = 1;
continue;
}
if (mask == DMA_BIT_MASK(32)) {
mask = DMA_BIT_MASK(30);
fallback = 1;
continue;
}
b43err(dev->wl, "The machine/kernel does not support "
"the required %u-bit DMA mask\n",
(unsigned int)dma_mask_to_engine_type(orig_mask));
return -EOPNOTSUPP;
}
if (fallback) {
b43info(dev->wl, "DMA mask fallback from %u-bit to %u-bit\n",
(unsigned int)dma_mask_to_engine_type(orig_mask),
(unsigned int)dma_mask_to_engine_type(mask));
}
return 0;
}
| 459 |
4,540 | 0 | static int X509_get_signature_nid(const X509 *x)
{
return OBJ_obj2nid(x->sig_alg->algorithm);
}
| 460 |
38,094 | 0 | static void stop_command_port(struct usb_serial *serial)
{
struct usb_serial_port *command_port;
struct whiteheat_command_private *command_info;
command_port = serial->port[COMMAND_PORT];
command_info = usb_get_serial_port_data(command_port);
mutex_lock(&command_info->mutex);
command_info->port_running--;
if (!command_info->port_running)
usb_kill_urb(command_port->read_urb);
mutex_unlock(&command_info->mutex);
}
| 461 |
180,532 | 1 | static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port)
{
struct cypress_private *priv = usb_get_serial_port_data(port);
struct usb_serial *serial = port->serial;
unsigned long flags;
int result = 0;
if (!priv->comm_is_ok)
return -EIO;
/* clear halts before open */
usb_clear_halt(serial->dev, 0x81);
usb_clear_halt(serial->dev, 0x02);
spin_lock_irqsave(&priv->lock, flags);
/* reset read/write statistics */
priv->bytes_in = 0;
priv->bytes_out = 0;
priv->cmd_count = 0;
priv->rx_flags = 0;
spin_unlock_irqrestore(&priv->lock, flags);
/* Set termios */
cypress_send(port);
if (tty)
cypress_set_termios(tty, port, &priv->tmp_termios);
/* setup the port and start reading from the device */
if (!port->interrupt_in_urb) {
dev_err(&port->dev, "%s - interrupt_in_urb is empty!\n",
__func__);
return -1;
}
usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress),
port->interrupt_in_urb->transfer_buffer,
port->interrupt_in_urb->transfer_buffer_length,
cypress_read_int_callback, port, priv->read_urb_interval);
result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
if (result) {
dev_err(&port->dev,
"%s - failed submitting read urb, error %d\n",
__func__, result);
cypress_set_dead(port);
}
return result;
} /* cypress_open */
| 462 |
53,985 | 0 | void ndp_set_log_priority(struct ndp *ndp, int priority)
{
ndp->log_priority = priority;
}
| 463 |
163,228 | 0 | NavigationLogger(WebContents* web_contents)
: WebContentsObserver(web_contents) {}
| 464 |
107,670 | 0 | const char* ewk_view_theme_get(const Evas_Object* ewkView)
{
EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
return priv->settings.theme;
}
| 465 |
84,494 | 0 | escdmap(char c)
{
int d;
d = (int)c - (int)'0';
c = getch();
if (IS_DIGIT(c)) {
d = d * 10 + (int)c - (int)'0';
c = getch();
}
if (c == '~')
escKeyProc((int)d, K_ESCD, EscDKeymap);
}
| 466 |
63,250 | 0 | void _WM_do_meta_smpteoffset(struct _mdi *mdi, struct _event_data *data) {
/* placeholder function so we can record tempo in the event stream
* for conversion function _WM_Event2Midi */
#ifdef DEBUG_MIDI
uint8_t ch = data->channel;
MIDI_EVENT_DEBUG(__FUNCTION__, ch, data->data.value);
#else
UNUSED(data);
#endif
UNUSED(mdi);
return;
}
| 467 |
175,601 | 0 | status_t NuMediaExtractor::setDataSource(int fd, off64_t offset, off64_t size) {
ALOGV("setDataSource fd=%d (%s), offset=%lld, length=%lld",
fd, nameForFd(fd).c_str(), (long long) offset, (long long) size);
Mutex::Autolock autoLock(mLock);
if (mImpl != NULL) {
return -EINVAL;
}
sp<FileSource> fileSource = new FileSource(dup(fd), offset, size);
status_t err = fileSource->initCheck();
if (err != OK) {
return err;
}
mImpl = MediaExtractor::Create(fileSource);
if (mImpl == NULL) {
return ERROR_UNSUPPORTED;
}
err = updateDurationAndBitrate();
if (err == OK) {
mDataSource = fileSource;
}
return OK;
}
| 468 |
104,416 | 0 | GLvoid StubGLBufferData(GLenum target, GLsizeiptr size, const void* data,
GLenum usage) {
glBufferData(target, size, data, usage);
}
| 469 |
94,876 | 0 | static int __usbnet_status_start_force(struct usbnet *dev, gfp_t mem_flags)
{
int ret = 0;
mutex_lock(&dev->interrupt_mutex);
if (dev->interrupt_count) {
ret = usb_submit_urb(dev->interrupt, mem_flags);
dev_dbg(&dev->udev->dev,
"submitted interrupt URB for resume\n");
}
mutex_unlock(&dev->interrupt_mutex);
return ret;
}
| 470 |
105,215 | 0 | bool shouldApplyWrappingStyle(Node* node) const
{
return m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNode() == node->parentNode()
&& m_wrappingStyle && m_wrappingStyle->style();
}
| 471 |
112,015 | 0 | bool SyncTest::TearDownLocalPythonTestServer() {
if (!sync_server_.Stop()) {
LOG(ERROR) << "Could not stop local python test server.";
return false;
}
xmpp_port_.reset();
return true;
}
| 472 |
41,708 | 0 | static void free_async_extent_pages(struct async_extent *async_extent)
{
int i;
if (!async_extent->pages)
return;
for (i = 0; i < async_extent->nr_pages; i++) {
WARN_ON(async_extent->pages[i]->mapping);
page_cache_release(async_extent->pages[i]);
}
kfree(async_extent->pages);
async_extent->nr_pages = 0;
async_extent->pages = NULL;
}
| 473 |
110,459 | 0 | void GLES2DecoderImpl::DoBufferData(
GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) {
if (!validators_->buffer_target.IsValid(target)) {
SetGLErrorInvalidEnum("glBufferData", target, "target");
return;
}
if (!validators_->buffer_usage.IsValid(usage)) {
SetGLErrorInvalidEnum("glBufferData", usage, "usage");
return;
}
if (size < 0) {
SetGLError(GL_INVALID_VALUE, "glBufferData", "size < 0");
return;
}
BufferManager::BufferInfo* info = GetBufferInfoForTarget(target);
if (!info) {
SetGLError(GL_INVALID_VALUE, "glBufferData", "unknown buffer");
return;
}
scoped_array<int8> zero;
if (!data) {
zero.reset(new int8[size]);
memset(zero.get(), 0, size);
data = zero.get();
}
if (!bufferdata_faster_than_buffersubdata_ &&
size == info->size() && usage == info->usage()) {
glBufferSubData(target, 0, size, data);
info->SetRange(0, size, data);
return;
}
CopyRealGLErrorsToWrapper();
glBufferData(target, size, data, usage);
GLenum error = PeekGLError();
if (error == GL_NO_ERROR) {
buffer_manager()->SetInfo(info, size, usage);
info->SetRange(0, size, data);
}
}
| 474 |
133,340 | 0 | void TestPaletteDelegate::CreateNote() {
++create_note_count_;
}
| 475 |
91,017 | 0 | void CWebServer::Cmd_SetUnused(WebEmSession & session, const request& req, Json::Value &root)
{
if (session.rights != 2)
{
session.reply_status = reply::forbidden;
return; //Only admin user allowed
}
std::string sidx = request::findValue(&req, "idx");
if (sidx.empty())
return;
int idx = atoi(sidx.c_str());
root["status"] = "OK";
root["title"] = "SetUnused";
m_sql.safe_query("UPDATE DeviceStatus SET Used=0 WHERE (ID == %d)", idx);
if (m_sql.m_bEnableEventSystem)
m_mainworker.m_eventsystem.RemoveSingleState(idx, m_mainworker.m_eventsystem.REASON_DEVICE);
#ifdef ENABLE_PYTHON
m_mainworker.m_pluginsystem.DeviceModified(idx);
#endif
}
| 476 |
79,659 | 0 | static char *convert_string(const char *bytes, ut32 len) {
ut32 idx = 0, pos = 0;
ut32 str_sz = 32 * len + 1;
char *cpy_buffer = len > 0 ? malloc (str_sz) : NULL;
if (!cpy_buffer) {
return cpy_buffer;
}
memset (cpy_buffer, 0, str_sz);
while (idx < len && pos < len) {
if (dso_json_char_needs_hexing (bytes[idx])) {
if (pos + 2 < len) {
free (cpy_buffer);
return NULL;
}
sprintf (cpy_buffer + pos, "\\x%02x", bytes[idx]);
pos += 4;
} else {
cpy_buffer[pos] = bytes[idx];
pos++;
}
idx++;
}
return cpy_buffer;
}
| 477 |
12,627 | 0 | DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes,
show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd,
"show ip bgp vpnv4 all neighbors A.B.C.D advertised-routes",
SHOW_STR
IP_STR
BGP_STR
"Display VPNv4 NLRI specific information\n"
"Display information about all VPNv4 NLRIs\n"
"Detailed information on TCP and BGP neighbor connections\n"
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n")
{
int ret;
struct peer *peer;
union sockunion su;
ret = str2sockunion (argv[0], &su);
if (ret < 0)
{
vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
peer = peer_lookup (NULL, &su);
if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])
{
vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
return CMD_WARNING;
}
return show_adj_route_vpn (vty, peer, NULL);
}
| 478 |
80,802 | 0 | GF_Err mvhd_dump(GF_Box *a, FILE * trace)
{
GF_MovieHeaderBox *p;
p = (GF_MovieHeaderBox *) a;
gf_isom_box_dump_start(a, "MovieHeaderBox", trace);
fprintf(trace, "CreationTime=\""LLD"\" ", LLD_CAST p->creationTime);
fprintf(trace, "ModificationTime=\""LLD"\" ", LLD_CAST p->modificationTime);
fprintf(trace, "TimeScale=\"%d\" ", p->timeScale);
fprintf(trace, "Duration=\""LLD"\" ", LLD_CAST p->duration);
fprintf(trace, "NextTrackID=\"%d\">\n", p->nextTrackID);
gf_isom_box_dump_done("MovieHeaderBox", a, trace);
return GF_OK;
}
| 479 |
53,187 | 0 | static struct async *async_getcompleted(struct usb_dev_state *ps)
{
unsigned long flags;
struct async *as = NULL;
spin_lock_irqsave(&ps->lock, flags);
if (!list_empty(&ps->async_completed)) {
as = list_entry(ps->async_completed.next, struct async,
asynclist);
list_del_init(&as->asynclist);
}
spin_unlock_irqrestore(&ps->lock, flags);
return as;
}
| 480 |
170,738 | 0 | status_t OMXNodeInstance::getState(OMX_STATETYPE* state) {
Mutex::Autolock autoLock(mLock);
OMX_ERRORTYPE err = OMX_GetState(mHandle, state);
CLOG_IF_ERROR(getState, err, "");
return StatusFromOMXError(err);
}
| 481 |
173,512 | 0 | OMX_ERRORTYPE omx_vdec::use_android_native_buffer(OMX_IN OMX_HANDLETYPE hComp, OMX_PTR data)
{
DEBUG_PRINT_LOW("Inside use_android_native_buffer");
OMX_ERRORTYPE eRet = OMX_ErrorNone;
UseAndroidNativeBufferParams *params = (UseAndroidNativeBufferParams *)data;
if ((params == NULL) ||
(params->nativeBuffer == NULL) ||
(params->nativeBuffer->handle == NULL) ||
!m_enable_android_native_buffers)
return OMX_ErrorBadParameter;
m_use_android_native_buffers = OMX_TRUE;
sp<android_native_buffer_t> nBuf = params->nativeBuffer;
private_handle_t *handle = (private_handle_t *)nBuf->handle;
if (OMX_CORE_OUTPUT_PORT_INDEX == params->nPortIndex) { //android native buffers can be used only on Output port
OMX_U8 *buffer = NULL;
if (!secure_mode) {
buffer = (OMX_U8*)mmap(0, handle->size,
PROT_READ|PROT_WRITE, MAP_SHARED, handle->fd, 0);
if (buffer == MAP_FAILED) {
DEBUG_PRINT_ERROR("Failed to mmap pmem with fd = %d, size = %d", handle->fd, handle->size);
return OMX_ErrorInsufficientResources;
}
}
eRet = use_buffer(hComp,params->bufferHeader,params->nPortIndex,data,handle->size,buffer);
} else {
eRet = OMX_ErrorBadParameter;
}
return eRet;
}
| 482 |
154,407 | 0 | SamplerManager* sampler_manager() {
return group_->sampler_manager();
}
| 483 |
105,000 | 0 | const char* HttpBridge::GetResponseContent() const {
DCHECK_EQ(MessageLoop::current(), created_on_loop_);
base::AutoLock lock(fetch_state_lock_);
DCHECK(fetch_state_.request_completed);
return fetch_state_.response_content.data();
}
| 484 |
22,742 | 0 | static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
struct in6_addr *saddr, struct in6_addr *daddr,
struct udp_table *udptable)
{
struct sock *sk, *stack[256 / sizeof(struct sock *)];
const struct udphdr *uh = udp_hdr(skb);
struct udp_hslot *hslot = udp_hashslot(udptable, net, ntohs(uh->dest));
int dif;
unsigned int i, count = 0;
spin_lock(&hslot->lock);
sk = sk_nulls_head(&hslot->head);
dif = inet6_iif(skb);
sk = udp_v6_mcast_next(net, sk, uh->dest, daddr, uh->source, saddr, dif);
while (sk) {
stack[count++] = sk;
sk = udp_v6_mcast_next(net, sk_nulls_next(sk), uh->dest, daddr,
uh->source, saddr, dif);
if (unlikely(count == ARRAY_SIZE(stack))) {
if (!sk)
break;
flush_stack(stack, count, skb, ~0);
count = 0;
}
}
/*
* before releasing the lock, we must take reference on sockets
*/
for (i = 0; i < count; i++)
sock_hold(stack[i]);
spin_unlock(&hslot->lock);
if (count) {
flush_stack(stack, count, skb, count - 1);
for (i = 0; i < count; i++)
sock_put(stack[i]);
} else {
kfree_skb(skb);
}
return 0;
}
| 485 |
174,257 | 0 | status_t Camera3Device::RequestThread::removeTriggers(
const sp<CaptureRequest> &request) {
Mutex::Autolock al(mTriggerMutex);
CameraMetadata &metadata = request->mSettings;
/**
* Replace all old entries with their old values.
*/
for (size_t i = 0; i < mTriggerReplacedMap.size(); ++i) {
RequestTrigger trigger = mTriggerReplacedMap.valueAt(i);
status_t res;
uint32_t tag = trigger.metadataTag;
switch (trigger.getTagType()) {
case TYPE_BYTE: {
uint8_t entryValue = static_cast<uint8_t>(trigger.entryValue);
res = metadata.update(tag,
&entryValue,
/*count*/1);
break;
}
case TYPE_INT32:
res = metadata.update(tag,
&trigger.entryValue,
/*count*/1);
break;
default:
ALOGE("%s: Type not supported: 0x%x",
__FUNCTION__,
trigger.getTagType());
return INVALID_OPERATION;
}
if (res != OK) {
ALOGE("%s: Failed to restore request metadata with trigger tag %s"
", trigger value %d", __FUNCTION__,
trigger.getTagName(), trigger.entryValue);
return res;
}
}
mTriggerReplacedMap.clear();
/**
* Remove all new entries.
*/
for (size_t i = 0; i < mTriggerRemovedMap.size(); ++i) {
RequestTrigger trigger = mTriggerRemovedMap.valueAt(i);
status_t res = metadata.erase(trigger.metadataTag);
if (res != OK) {
ALOGE("%s: Failed to erase metadata with trigger tag %s"
", trigger value %d", __FUNCTION__,
trigger.getTagName(), trigger.entryValue);
return res;
}
}
mTriggerRemovedMap.clear();
return OK;
}
| 486 |
70,064 | 0 | int restartServer(int flags, mstime_t delay) {
int j;
/* Check if we still have accesses to the executable that started this
* server instance. */
if (access(server.executable,X_OK) == -1) return C_ERR;
/* Config rewriting. */
if (flags & RESTART_SERVER_CONFIG_REWRITE &&
server.configfile &&
rewriteConfig(server.configfile) == -1) return C_ERR;
/* Perform a proper shutdown. */
if (flags & RESTART_SERVER_GRACEFULLY &&
prepareForShutdown(SHUTDOWN_NOFLAGS) != C_OK) return C_ERR;
/* Close all file descriptors, with the exception of stdin, stdout, strerr
* which are useful if we restart a Redis server which is not daemonized. */
for (j = 3; j < (int)server.maxclients + 1024; j++) close(j);
/* Execute the server with the original command line. */
if (delay) usleep(delay*1000);
execve(server.executable,server.exec_argv,environ);
/* If an error occurred here, there is nothing we can do, but exit. */
_exit(1);
return C_ERR; /* Never reached. */
}
| 487 |
75,539 | 0 | static unsigned usb_bus_is_wusb(struct usb_bus *bus)
{
struct usb_hcd *hcd = bus_to_hcd(bus);
return hcd->wireless;
}
| 488 |
46,745 | 0 | static int cbc_encrypt(struct blkcipher_desc *desc,
struct scatterlist *dst, struct scatterlist *src,
unsigned int nbytes)
{
struct camellia_sparc64_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
struct blkcipher_walk walk;
cbc_crypt_op *op;
const u64 *key;
int err;
op = camellia_sparc64_cbc_encrypt_3_grand_rounds;
if (ctx->key_len != 16)
op = camellia_sparc64_cbc_encrypt_4_grand_rounds;
blkcipher_walk_init(&walk, dst, src, nbytes);
err = blkcipher_walk_virt(desc, &walk);
desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
key = &ctx->encrypt_key[0];
camellia_sparc64_load_keys(key, ctx->key_len);
while ((nbytes = walk.nbytes)) {
unsigned int block_len = nbytes & CAMELLIA_BLOCK_MASK;
if (likely(block_len)) {
const u64 *src64;
u64 *dst64;
src64 = (const u64 *)walk.src.virt.addr;
dst64 = (u64 *) walk.dst.virt.addr;
op(src64, dst64, block_len, key,
(u64 *) walk.iv);
}
nbytes &= CAMELLIA_BLOCK_SIZE - 1;
err = blkcipher_walk_done(desc, &walk, nbytes);
}
fprs_write(0);
return err;
}
| 489 |
27,477 | 0 | static inline struct ip_tunnel **ipgre_bucket(struct ipgre_net *ign,
struct ip_tunnel *t)
{
return __ipgre_bucket(ign, &t->parms);
}
| 490 |
11,911 | 0 | int CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,
ASN1_OCTET_STRING **keyid,
X509_NAME **issuer,
ASN1_INTEGER **sno)
{
CMS_KeyTransRecipientInfo *ktri;
if (ri->type != CMS_RECIPINFO_TRANS) {
CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID,
CMS_R_NOT_KEY_TRANSPORT);
return 0;
}
ktri = ri->d.ktri;
return cms_SignerIdentifier_get0_signer_id(ktri->rid, keyid, issuer, sno);
}
| 491 |
111,435 | 0 | WebPage::~WebPage()
{
deleteGuardedObject(d);
d = 0;
}
| 492 |
114,292 | 0 | void WebGraphicsContext3DCommandBufferImpl::copyTextureToParentTextureCHROMIUM(
WebGLId texture, WebGLId parentTexture) {
NOTIMPLEMENTED();
}
| 493 |
27,335 | 0 | static void ip4_frag_init(struct inet_frag_queue *q, void *a)
{
struct ipq *qp = container_of(q, struct ipq, q);
struct ip4_create_arg *arg = a;
qp->protocol = arg->iph->protocol;
qp->id = arg->iph->id;
qp->ecn = ip4_frag_ecn(arg->iph->tos);
qp->saddr = arg->iph->saddr;
qp->daddr = arg->iph->daddr;
qp->user = arg->user;
qp->peer = sysctl_ipfrag_max_dist ?
inet_getpeer_v4(arg->iph->saddr, 1) : NULL;
}
| 494 |
65,194 | 0 | static void grace_ender(struct work_struct *grace)
{
struct delayed_work *dwork = to_delayed_work(grace);
struct lockd_net *ln = container_of(dwork, struct lockd_net,
grace_period_end);
locks_end_grace(&ln->lockd_manager);
}
| 495 |
49,487 | 0 | static void hid_device_release(struct device *dev)
{
struct hid_device *hid = to_hid_device(dev);
hid_close_report(hid);
kfree(hid->dev_rdesc);
kfree(hid);
}
| 496 |
171,496 | 0 | WORD32 ih264d_set_flush_mode(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op)
{
dec_struct_t * ps_dec;
ivd_ctl_flush_op_t *ps_ctl_op = (ivd_ctl_flush_op_t*)pv_api_op;
ps_ctl_op->u4_error_code = 0;
ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle);
UNUSED(pv_api_ip);
/* ! */
/* Signal flush frame control call */
ps_dec->u1_flushfrm = 1;
if(ps_dec->u1_init_dec_flag == 1)
{
ih264d_release_pics_in_dpb((void *)ps_dec, ps_dec->u1_pic_bufs);
ih264d_release_display_bufs(ps_dec);
}
ps_ctl_op->u4_error_code = 0;
return IV_SUCCESS;
}
| 497 |
66,076 | 0 | static void edge_heartbeat_schedule(struct edgeport_serial *edge_serial)
{
if (!edge_serial->use_heartbeat)
return;
schedule_delayed_work(&edge_serial->heartbeat_work,
FW_HEARTBEAT_SECS * HZ);
}
| 498 |
178,263 | 1 | my_object_dict_of_dicts (MyObject *obj, GHashTable *in,
GHashTable **out, GError **error)
{
*out = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_hash_table_destroy);
g_hash_table_foreach (in, hash_foreach_mangle_dict_of_strings, *out);
return TRUE;
}
| 499 |
Subsets and Splits