unique_id
int64 13
189k
| target
int64 0
1
| code
stringlengths 20
241k
| __index_level_0__
int64 0
18.9k
|
---|---|---|---|
65,959 | 0 | static int read_reset_stat(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
{
atomic_t *stat = (atomic_t *)table->data;
if (!stat)
return -EINVAL;
if (write)
atomic_set(stat, 0);
else {
char str_buf[32];
char *data;
int len = snprintf(str_buf, 32, "%d\n", atomic_read(stat));
if (len >= 32)
return -EFAULT;
len = strlen(str_buf);
if (*ppos > len) {
*lenp = 0;
return 0;
}
data = &str_buf[*ppos];
len -= *ppos;
if (len > *lenp)
len = *lenp;
if (len && copy_to_user(buffer, str_buf, len))
return -EFAULT;
*lenp = len;
*ppos += len;
}
return 0;
}
| 1,500 |
113,071 | 0 | bool DownloadItemImpl::IsComplete() const {
return (state_ == COMPLETE);
}
| 1,501 |
53,687 | 0 | static int ipv6_renew_option(void *ohdr,
struct ipv6_opt_hdr __user *newopt, int newoptlen,
int inherit,
struct ipv6_opt_hdr **hdr,
char **p)
{
if (inherit) {
if (ohdr) {
memcpy(*p, ohdr, ipv6_optlen((struct ipv6_opt_hdr *)ohdr));
*hdr = (struct ipv6_opt_hdr *)*p;
*p += CMSG_ALIGN(ipv6_optlen(*hdr));
}
} else {
if (newopt) {
if (copy_from_user(*p, newopt, newoptlen))
return -EFAULT;
*hdr = (struct ipv6_opt_hdr *)*p;
if (ipv6_optlen(*hdr) > newoptlen)
return -EINVAL;
*p += CMSG_ALIGN(newoptlen);
}
}
return 0;
}
| 1,502 |
59,233 | 0 | get_pa_etype_info(krb5_context context,
krb5_kdc_configuration *config,
METHOD_DATA *md, Key *ckey)
{
krb5_error_code ret = 0;
ETYPE_INFO pa;
unsigned char *buf;
size_t len;
pa.len = 1;
pa.val = calloc(1, sizeof(pa.val[0]));
if(pa.val == NULL)
return ENOMEM;
ret = make_etype_info_entry(context, &pa.val[0], ckey);
if (ret) {
free_ETYPE_INFO(&pa);
return ret;
}
ASN1_MALLOC_ENCODE(ETYPE_INFO, buf, len, &pa, &len, ret);
free_ETYPE_INFO(&pa);
if(ret)
return ret;
ret = realloc_method_data(md);
if(ret) {
free(buf);
return ret;
}
md->val[md->len - 1].padata_type = KRB5_PADATA_ETYPE_INFO;
md->val[md->len - 1].padata_value.length = len;
md->val[md->len - 1].padata_value.data = buf;
return 0;
}
| 1,503 |
3,968 | 0 | int FileOutStream::getPos ()
{
return ftell(f);
}
| 1,504 |
170,323 | 0 | SampleTable::CompositionDeltaLookup::CompositionDeltaLookup()
: mDeltaEntries(NULL),
mNumDeltaEntries(0),
mCurrentDeltaEntry(0),
mCurrentEntrySampleIndex(0) {
}
| 1,505 |
4,175 | 0 | tt_cmap10_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
FT_Byte* table = cmap->data;
FT_UInt result = 0;
FT_Byte* p = table + 12;
FT_UInt32 start = TT_NEXT_ULONG( p );
FT_UInt32 count = TT_NEXT_ULONG( p );
FT_UInt32 idx = (FT_ULong)( char_code - start );
if ( idx < count )
{
p += 2 * idx;
result = TT_PEEK_USHORT( p );
}
return result;
}
| 1,506 |
42,080 | 0 | static void initialize_dirent_tail(struct ext4_dir_entry_tail *t,
unsigned int blocksize)
{
memset(t, 0, sizeof(struct ext4_dir_entry_tail));
t->det_rec_len = ext4_rec_len_to_disk(
sizeof(struct ext4_dir_entry_tail), blocksize);
t->det_reserved_ft = EXT4_FT_DIR_CSUM;
}
| 1,507 |
29,521 | 0 | static inline int pipelined_send(struct msg_queue *msq, struct msg_msg *msg)
{
struct list_head *tmp;
tmp = msq->q_receivers.next;
while (tmp != &msq->q_receivers) {
struct msg_receiver *msr;
msr = list_entry(tmp, struct msg_receiver, r_list);
tmp = tmp->next;
if (testmsg(msg, msr->r_msgtype, msr->r_mode) &&
!security_msg_queue_msgrcv(msq, msg, msr->r_tsk,
msr->r_msgtype, msr->r_mode)) {
list_del(&msr->r_list);
if (msr->r_maxsize < msg->m_ts) {
msr->r_msg = NULL;
wake_up_process(msr->r_tsk);
smp_mb();
msr->r_msg = ERR_PTR(-E2BIG);
} else {
msr->r_msg = NULL;
msq->q_lrpid = task_pid_vnr(msr->r_tsk);
msq->q_rtime = get_seconds();
wake_up_process(msr->r_tsk);
smp_mb();
msr->r_msg = msg;
return 1;
}
}
}
return 0;
}
| 1,508 |
136,129 | 0 | MockWebsiteSettingsUI* mock_ui() { return mock_ui_.get(); }
| 1,509 |
112,366 | 0 | ResourceDispatcherHostImpl::ResourceDispatcherHostImpl()
: download_file_manager_(new DownloadFileManager(NULL)),
save_file_manager_(new SaveFileManager()),
request_id_(-1),
is_shutdown_(false),
max_outstanding_requests_cost_per_process_(
kMaxOutstandingRequestsCostPerProcess),
filter_(NULL),
delegate_(NULL),
allow_cross_origin_auth_prompt_(false) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!g_resource_dispatcher_host);
g_resource_dispatcher_host = this;
GetContentClient()->browser()->ResourceDispatcherHostCreated();
ANNOTATE_BENIGN_RACE(
&last_user_gesture_time_,
"We don't care about the precise value, see http://crbug.com/92889");
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&appcache::AppCacheInterceptor::EnsureRegistered));
update_load_states_timer_.reset(
new base::RepeatingTimer<ResourceDispatcherHostImpl>());
}
| 1,510 |
119,661 | 0 | void setFloatIndex(unsigned floatIndex) { m_floatIndex = floatIndex; }
| 1,511 |
26,667 | 0 | static int nl80211_cancel_remain_on_channel(struct sk_buff *skb,
struct genl_info *info)
{
struct cfg80211_registered_device *rdev = info->user_ptr[0];
struct net_device *dev = info->user_ptr[1];
u64 cookie;
if (!info->attrs[NL80211_ATTR_COOKIE])
return -EINVAL;
if (!rdev->ops->cancel_remain_on_channel)
return -EOPNOTSUPP;
cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]);
return rdev->ops->cancel_remain_on_channel(&rdev->wiphy, dev, cookie);
}
| 1,512 |
164,690 | 0 | void RenderFrameHostImpl::DidCommitSameDocumentNavigation(
std::unique_ptr<FrameHostMsg_DidCommitProvisionalLoad_Params>
validated_params) {
ScopedActiveURL scoped_active_url(
validated_params->url,
frame_tree_node()->frame_tree()->root()->current_origin());
ScopedCommitStateResetter commit_state_resetter(this);
if (!is_active())
return;
TRACE_EVENT2("navigation",
"RenderFrameHostImpl::DidCommitSameDocumentNavigation",
"frame_tree_node", frame_tree_node_->frame_tree_node_id(), "url",
validated_params->url.possibly_invalid_spec());
bool is_browser_initiated = (validated_params->nav_entry_id != 0);
if (!DidCommitNavigationInternal(
is_browser_initiated ? std::move(same_document_navigation_request_)
: nullptr,
validated_params.get(), true /* is_same_document_navigation*/)) {
return;
}
commit_state_resetter.disable();
}
| 1,513 |
146,450 | 0 | void WebGLRenderingContextBase::blendFunc(GLenum sfactor, GLenum dfactor) {
if (isContextLost() ||
!ValidateBlendFuncFactors("blendFunc", sfactor, dfactor))
return;
ContextGL()->BlendFunc(sfactor, dfactor);
}
| 1,514 |
114,903 | 0 | IPC::Channel::Mode TestingAutomationProvider::GetChannelMode(
bool use_named_interface) {
if (use_named_interface)
#if defined(OS_POSIX)
return IPC::Channel::MODE_OPEN_NAMED_SERVER;
#else
return IPC::Channel::MODE_NAMED_SERVER;
#endif
else
return IPC::Channel::MODE_CLIENT;
}
| 1,515 |
80,585 | 0 | GF_Err trep_Size(GF_Box *s)
{
GF_TrackExtensionPropertiesBox *ptr = (GF_TrackExtensionPropertiesBox *)s;
ptr->size += 4;
return GF_OK;
}
| 1,516 |
186,611 | 1 | bool MediaElementAudioSourceHandler::WouldTaintOrigin() {
// If we're cross-origin and allowed access vie CORS, we're not tainted.
if (MediaElement()->GetWebMediaPlayer()->DidPassCORSAccessCheck()) {
return false;
}
// Handles the case where the url is a redirect to another site that we're not
// allowed to access.
if (!MediaElement()->HasSingleSecurityOrigin()) {
return true;
}
// Test to see if the current media URL taint the origin of the audio context?
return Context()->WouldTaintOrigin(MediaElement()->currentSrc());
}
| 1,517 |
96,991 | 0 | static void __init gather_bootmem_prealloc(void)
{
struct huge_bootmem_page *m;
list_for_each_entry(m, &huge_boot_pages, list) {
struct page *page = virt_to_page(m);
struct hstate *h = m->hstate;
WARN_ON(page_count(page) != 1);
prep_compound_huge_page(page, h->order);
WARN_ON(PageReserved(page));
prep_new_huge_page(h, page, page_to_nid(page));
put_page(page); /* free it into the hugepage allocator */
/*
* If we had gigantic hugepages allocated at boot time, we need
* to restore the 'stolen' pages to totalram_pages in order to
* fix confusing memory reports from free(1) and another
* side-effects, like CommitLimit going negative.
*/
if (hstate_is_gigantic(h))
adjust_managed_page_count(page, 1 << h->order);
cond_resched();
}
}
| 1,518 |
100,781 | 0 | void HttpResponseHeaders::AddNonCacheableHeaders(HeaderSet* result) const {
const std::string kCacheControl = "cache-control";
const std::string kPrefix = "no-cache=\"";
std::string value;
void* iter = NULL;
while (EnumerateHeader(&iter, kCacheControl, &value)) {
if (value.size() > kPrefix.size() &&
value.compare(0, kPrefix.size(), kPrefix) == 0) {
if (value[value.size()-1] != '\"')
continue;
size_t len = value.size() - kPrefix.size() - 1;
TrimString(value.substr(kPrefix.size(), len), HTTP_LWS, &value);
size_t begin_pos = 0;
for (;;) {
size_t comma_pos = value.find(',', begin_pos);
if (comma_pos == std::string::npos)
comma_pos = value.size();
size_t end = comma_pos;
while (end > begin_pos && strchr(HTTP_LWS, value[end - 1]))
end--;
if (end > begin_pos) {
std::string name = value.substr(begin_pos, end - begin_pos);
StringToLowerASCII(&name);
result->insert(name);
}
begin_pos = comma_pos + 1;
while (begin_pos < value.size() && strchr(HTTP_LWS, value[begin_pos]))
begin_pos++;
if (begin_pos >= value.size())
break;
}
}
}
}
| 1,519 |
98,038 | 0 | void RenderView::UserMetricsRecordAction(const std::string& action) {
Send(new ViewHostMsg_UserMetricsRecordAction(routing_id_, action));
}
| 1,520 |
8,388 | 0 | static void mptsas_soft_reset(MPTSASState *s)
{
uint32_t save_mask;
trace_mptsas_reset(s);
/* Temporarily disable interrupts */
save_mask = s->intr_mask;
s->intr_mask = MPI_HIM_DIM | MPI_HIM_RIM;
mptsas_update_interrupt(s);
qbus_reset_all(&s->bus.qbus);
s->intr_status = 0;
s->intr_mask = save_mask;
s->reply_free_tail = 0;
s->reply_free_head = 0;
s->reply_post_tail = 0;
s->reply_post_head = 0;
s->request_post_tail = 0;
s->request_post_head = 0;
qemu_bh_cancel(s->request_bh);
s->state = MPI_IOC_STATE_READY;
}
| 1,521 |
121,139 | 0 | void HTMLInputElement::defaultBlur()
{
HTMLTextFormControlElement::blur();
}
| 1,522 |
61,323 | 0 | static const char *csv_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
{
char meta_chars[] = { sep, '"', '\n', '\r', '\0' };
int needs_quoting = !!src[strcspn(src, meta_chars)];
if (needs_quoting)
av_bprint_chars(dst, '"', 1);
for (; *src; src++) {
if (*src == '"')
av_bprint_chars(dst, '"', 1);
av_bprint_chars(dst, *src, 1);
}
if (needs_quoting)
av_bprint_chars(dst, '"', 1);
return dst->str;
}
| 1,523 |
76,603 | 0 | static int fsck_commit_buffer(struct commit *commit, const char *buffer,
unsigned long size, struct fsck_options *options)
{
unsigned char tree_sha1[20], sha1[20];
struct commit_graft *graft;
unsigned parent_count, parent_line_count = 0, author_count;
int err;
const char *buffer_begin = buffer;
if (verify_headers(buffer, size, &commit->object, options))
return -1;
if (!skip_prefix(buffer, "tree ", &buffer))
return report(options, &commit->object, FSCK_MSG_MISSING_TREE, "invalid format - expected 'tree' line");
if (get_sha1_hex(buffer, tree_sha1) || buffer[40] != '\n') {
err = report(options, &commit->object, FSCK_MSG_BAD_TREE_SHA1, "invalid 'tree' line format - bad sha1");
if (err)
return err;
}
buffer += 41;
while (skip_prefix(buffer, "parent ", &buffer)) {
if (get_sha1_hex(buffer, sha1) || buffer[40] != '\n') {
err = report(options, &commit->object, FSCK_MSG_BAD_PARENT_SHA1, "invalid 'parent' line format - bad sha1");
if (err)
return err;
}
buffer += 41;
parent_line_count++;
}
graft = lookup_commit_graft(&commit->object.oid);
parent_count = commit_list_count(commit->parents);
if (graft) {
if (graft->nr_parent == -1 && !parent_count)
; /* shallow commit */
else if (graft->nr_parent != parent_count) {
err = report(options, &commit->object, FSCK_MSG_MISSING_GRAFT, "graft objects missing");
if (err)
return err;
}
} else {
if (parent_count != parent_line_count) {
err = report(options, &commit->object, FSCK_MSG_MISSING_PARENT, "parent objects missing");
if (err)
return err;
}
}
author_count = 0;
while (skip_prefix(buffer, "author ", &buffer)) {
author_count++;
err = fsck_ident(&buffer, &commit->object, options);
if (err)
return err;
}
if (author_count < 1)
err = report(options, &commit->object, FSCK_MSG_MISSING_AUTHOR, "invalid format - expected 'author' line");
else if (author_count > 1)
err = report(options, &commit->object, FSCK_MSG_MULTIPLE_AUTHORS, "invalid format - multiple 'author' lines");
if (err)
return err;
if (!skip_prefix(buffer, "committer ", &buffer))
return report(options, &commit->object, FSCK_MSG_MISSING_COMMITTER, "invalid format - expected 'committer' line");
err = fsck_ident(&buffer, &commit->object, options);
if (err)
return err;
if (!commit->tree) {
err = report(options, &commit->object, FSCK_MSG_BAD_TREE, "could not load commit's tree %s", sha1_to_hex(tree_sha1));
if (err)
return err;
}
if (memchr(buffer_begin, '\0', size)) {
err = report(options, &commit->object, FSCK_MSG_NUL_IN_COMMIT,
"NUL byte in the commit object body");
if (err)
return err;
}
return 0;
}
| 1,524 |
111,633 | 0 | std::string ExtractResourceId(const GURL& url) {
return net::UnescapeURLComponent(url.ExtractFileName(),
net::UnescapeRule::URL_SPECIAL_CHARS);
}
| 1,525 |
147,665 | 0 | static void OverloadedPerWorldBindingsMethod2MethodForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info) {
ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestObject", "overloadedPerWorldBindingsMethod");
TestObject* impl = V8TestObject::ToImpl(info.Holder());
int32_t long_arg;
long_arg = NativeValueTraits<IDLLong>::NativeValue(info.GetIsolate(), info[0], exception_state);
if (exception_state.HadException())
return;
impl->overloadedPerWorldBindingsMethod(long_arg);
}
| 1,526 |
113,754 | 0 | void PrintPreviewMessageHandler::OnDidPreviewPage(
const PrintHostMsg_DidPreviewPage_Params& params) {
int page_number = params.page_number;
if (page_number < FIRST_PAGE_INDEX || !params.data_size)
return;
PrintPreviewUI* print_preview_ui = GetPrintPreviewUI();
if (!print_preview_ui)
return;
base::RefCountedBytes* data_bytes =
GetDataFromHandle(params.metafile_data_handle, params.data_size);
DCHECK(data_bytes);
print_preview_ui->SetPrintPreviewDataForIndex(page_number, data_bytes);
print_preview_ui->OnDidPreviewPage(page_number, params.preview_request_id);
}
| 1,527 |
64,813 | 0 | void skcipher_walk_complete(struct skcipher_walk *walk, int err)
{
struct skcipher_walk_buffer *p, *tmp;
list_for_each_entry_safe(p, tmp, &walk->buffers, entry) {
u8 *data;
if (err)
goto done;
data = p->data;
if (!data) {
data = PTR_ALIGN(&p->buffer[0], walk->alignmask + 1);
data = skcipher_get_spot(data, walk->stride);
}
scatterwalk_copychunks(data, &p->dst, p->len, 1);
if (offset_in_page(p->data) + p->len + walk->stride >
PAGE_SIZE)
free_page((unsigned long)p->data);
done:
list_del(&p->entry);
kfree(p);
}
if (!err && walk->iv != walk->oiv)
memcpy(walk->oiv, walk->iv, walk->ivsize);
if (walk->buffer != walk->page)
kfree(walk->buffer);
if (walk->page)
free_page((unsigned long)walk->page);
}
| 1,528 |
58,242 | 0 | static void ttwu_queue(struct task_struct *p, int cpu)
{
struct rq *rq = cpu_rq(cpu);
#if defined(CONFIG_SMP)
if (sched_feat(TTWU_QUEUE) && !cpus_share_cache(smp_processor_id(), cpu)) {
sched_clock_cpu(cpu); /* sync clocks x-cpu */
ttwu_queue_remote(p, cpu);
return;
}
#endif
raw_spin_lock(&rq->lock);
ttwu_do_activate(rq, p, 0);
raw_spin_unlock(&rq->lock);
}
| 1,529 |
167,998 | 0 | void DocumentLoader::DidInstallNewDocument(Document* document) {
document->SetReadyState(Document::kLoading);
if (content_security_policy_) {
document->InitContentSecurityPolicy(content_security_policy_.Release());
}
if (history_item_ && IsBackForwardLoadType(load_type_))
document->SetStateForNewFormElements(history_item_->GetDocumentState());
document->GetClientHintsPreferences().UpdateFrom(client_hints_preferences_);
Settings* settings = document->GetSettings();
fetcher_->SetImagesEnabled(settings->GetImagesEnabled());
fetcher_->SetAutoLoadImages(settings->GetLoadsImagesAutomatically());
const AtomicString& dns_prefetch_control =
response_.HttpHeaderField(HTTPNames::X_DNS_Prefetch_Control);
if (!dns_prefetch_control.IsEmpty())
document->ParseDNSPrefetchControlHeader(dns_prefetch_control);
String header_content_language =
response_.HttpHeaderField(HTTPNames::Content_Language);
if (!header_content_language.IsEmpty()) {
size_t comma_index = header_content_language.find(',');
header_content_language.Truncate(comma_index);
header_content_language =
header_content_language.StripWhiteSpace(IsHTMLSpace<UChar>);
if (!header_content_language.IsEmpty())
document->SetContentLanguage(AtomicString(header_content_language));
}
String referrer_policy_header =
response_.HttpHeaderField(HTTPNames::Referrer_Policy);
if (!referrer_policy_header.IsNull()) {
UseCounter::Count(*document, WebFeature::kReferrerPolicyHeader);
document->ParseAndSetReferrerPolicy(referrer_policy_header);
}
GetLocalFrameClient().DidCreateNewDocument();
}
| 1,530 |
28,464 | 0 | static ssize_t aac_show_raid_level(struct device *dev, struct device_attribute *attr, char *buf)
{
struct scsi_device *sdev = to_scsi_device(dev);
struct aac_dev *aac = (struct aac_dev *)(sdev->host->hostdata);
if (sdev_channel(sdev) != CONTAINER_CHANNEL)
return snprintf(buf, PAGE_SIZE, sdev->no_uld_attach
? "Hidden\n" :
((aac->jbod && (sdev->type == TYPE_DISK)) ? "JBOD\n" : ""));
return snprintf(buf, PAGE_SIZE, "%s\n",
get_container_type(aac->fsa_dev[sdev_id(sdev)].type));
}
| 1,531 |
7,271 | 0 | static void sapi_fcgi_flush(void *server_context)
{
fcgi_request *request = (fcgi_request*) server_context;
if (
#ifndef PHP_WIN32
!parent &&
#endif
request && !fcgi_flush(request, 0)) {
php_handle_aborted_connection();
}
}
| 1,532 |
13,630 | 0 | static void free_sessions(void)
{
simple_ssl_session *sess, *tsess;
for (sess = first; sess;) {
OPENSSL_free(sess->id);
OPENSSL_free(sess->der);
tsess = sess;
sess = sess->next;
OPENSSL_free(tsess);
}
first = NULL;
}
| 1,533 |
133,924 | 0 | bool AppListControllerDelegate::IsExtensionInstalled(
Profile* profile, const std::string& app_id) {
return !!GetExtension(profile, app_id);
}
| 1,534 |
145,744 | 0 | void ModuleSystem::RegisterNativeHandler(
const std::string& name,
scoped_ptr<NativeHandler> native_handler) {
ClobberExistingNativeHandler(name);
native_handler_map_[name] =
linked_ptr<NativeHandler>(native_handler.release());
}
| 1,535 |
126,689 | 0 | State(WebContents* a_dst_contents,
int a_dst_index,
TabStripModelObserverAction a_action)
: src_contents(NULL),
dst_contents(a_dst_contents),
src_index(-1),
dst_index(a_dst_index),
user_gesture(false),
foreground(false),
action(a_action) {
}
| 1,536 |
139,345 | 0 | HostCache::Entry::Entry(int error,
const AddressList& addresses,
base::TimeTicks expires,
int network_changes)
: error_(error),
addresses_(addresses),
ttl_(base::TimeDelta::FromSeconds(-1)),
expires_(expires),
network_changes_(network_changes),
total_hits_(0),
stale_hits_(0) {}
| 1,537 |
162,692 | 0 | BaseRenderingContext2D::GetUsage() {
return usage_counters_;
}
| 1,538 |
71,042 | 0 | void *Type_ProfileSequenceId_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
{
cmsSEQ* OutSeq;
cmsUInt32Number Count;
cmsUInt32Number BaseOffset;
*nItems = 0;
BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
if (!_cmsReadUInt32Number(io, &Count)) return NULL;
SizeOfTag -= sizeof(cmsUInt32Number);
OutSeq = cmsAllocProfileSequenceDescription(self ->ContextID, Count);
if (OutSeq == NULL) return NULL;
if (!ReadPositionTable(self, io, Count, BaseOffset, OutSeq, ReadSeqID)) {
cmsFreeProfileSequenceDescription(OutSeq);
return NULL;
}
*nItems = 1;
return OutSeq;
}
| 1,539 |
46,705 | 0 | static int ecb_desall_crypt(struct blkcipher_desc *desc, long func,
u8 *key, struct blkcipher_walk *walk)
{
int ret = blkcipher_walk_virt(desc, walk);
unsigned int nbytes;
while ((nbytes = walk->nbytes)) {
/* only use complete blocks */
unsigned int n = nbytes & ~(DES_BLOCK_SIZE - 1);
u8 *out = walk->dst.virt.addr;
u8 *in = walk->src.virt.addr;
ret = crypt_s390_km(func, key, out, in, n);
if (ret < 0 || ret != n)
return -EIO;
nbytes &= DES_BLOCK_SIZE - 1;
ret = blkcipher_walk_done(desc, walk, nbytes);
}
return ret;
}
| 1,540 |
2,417 | 0 | NTSTATUS smb1cli_req_recv(struct tevent_req *req,
TALLOC_CTX *mem_ctx,
struct iovec **piov,
uint8_t **phdr,
uint8_t *pwct,
uint16_t **pvwv,
uint32_t *pvwv_offset,
uint32_t *pnum_bytes,
uint8_t **pbytes,
uint32_t *pbytes_offset,
uint8_t **pinbuf,
const struct smb1cli_req_expected_response *expected,
size_t num_expected)
{
struct smbXcli_req_state *state =
tevent_req_data(req,
struct smbXcli_req_state);
NTSTATUS status = NT_STATUS_OK;
struct iovec *recv_iov = NULL;
uint8_t *hdr = NULL;
uint8_t wct = 0;
uint32_t vwv_offset = 0;
uint16_t *vwv = NULL;
uint32_t num_bytes = 0;
uint32_t bytes_offset = 0;
uint8_t *bytes = NULL;
size_t i;
bool found_status = false;
bool found_size = false;
if (piov != NULL) {
*piov = NULL;
}
if (phdr != NULL) {
*phdr = 0;
}
if (pwct != NULL) {
*pwct = 0;
}
if (pvwv != NULL) {
*pvwv = NULL;
}
if (pvwv_offset != NULL) {
*pvwv_offset = 0;
}
if (pnum_bytes != NULL) {
*pnum_bytes = 0;
}
if (pbytes != NULL) {
*pbytes = NULL;
}
if (pbytes_offset != NULL) {
*pbytes_offset = 0;
}
if (pinbuf != NULL) {
*pinbuf = NULL;
}
if (state->inbuf != NULL) {
recv_iov = state->smb1.recv_iov;
state->smb1.recv_iov = NULL;
if (state->smb1.recv_cmd != SMBreadBraw) {
hdr = (uint8_t *)recv_iov[0].iov_base;
wct = recv_iov[1].iov_len/2;
vwv = (uint16_t *)recv_iov[1].iov_base;
vwv_offset = PTR_DIFF(vwv, hdr);
num_bytes = recv_iov[2].iov_len;
bytes = (uint8_t *)recv_iov[2].iov_base;
bytes_offset = PTR_DIFF(bytes, hdr);
}
}
if (tevent_req_is_nterror(req, &status)) {
for (i=0; i < num_expected; i++) {
if (NT_STATUS_EQUAL(status, expected[i].status)) {
found_status = true;
break;
}
}
if (found_status) {
return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
}
return status;
}
if (num_expected == 0) {
found_status = true;
found_size = true;
}
status = state->smb1.recv_status;
for (i=0; i < num_expected; i++) {
if (!NT_STATUS_EQUAL(status, expected[i].status)) {
continue;
}
found_status = true;
if (expected[i].wct == 0) {
found_size = true;
break;
}
if (expected[i].wct == wct) {
found_size = true;
break;
}
}
if (!found_status) {
return status;
}
if (!found_size) {
return NT_STATUS_INVALID_NETWORK_RESPONSE;
}
if (piov != NULL) {
*piov = talloc_move(mem_ctx, &recv_iov);
}
if (phdr != NULL) {
*phdr = hdr;
}
if (pwct != NULL) {
*pwct = wct;
}
if (pvwv != NULL) {
*pvwv = vwv;
}
if (pvwv_offset != NULL) {
*pvwv_offset = vwv_offset;
}
if (pnum_bytes != NULL) {
*pnum_bytes = num_bytes;
}
if (pbytes != NULL) {
*pbytes = bytes;
}
if (pbytes_offset != NULL) {
*pbytes_offset = bytes_offset;
}
if (pinbuf != NULL) {
*pinbuf = state->inbuf;
}
return status;
}
| 1,541 |
183,639 | 1 | string16 ExtensionInstallUI::Prompt::GetHeading(std::string extension_name)
const {
if (type_ == INLINE_INSTALL_PROMPT) {
return UTF8ToUTF16(extension_name);
} else {
return l10n_util::GetStringFUTF16(
kHeadingIds[type_], UTF8ToUTF16(extension_name));
}
}
| 1,542 |
101,217 | 0 | void Syncer::RequestEarlyExit() {
base::AutoLock lock(early_exit_requested_lock_);
early_exit_requested_ = true;
}
| 1,543 |
100,460 | 0 | void WebSettingsImpl::setAllowScriptsToCloseWindows(bool allow)
{
m_settings->setAllowScriptsToCloseWindows(allow);
}
| 1,544 |
123,534 | 0 | const FilePath::CharType* SavePackage::ExtensionForMimeType(
const std::string& contents_mime_type) {
static const struct {
const FilePath::CharType *mime_type;
const FilePath::CharType *suggested_extension;
} extensions[] = {
{ FILE_PATH_LITERAL("text/html"), kDefaultHtmlExtension },
{ FILE_PATH_LITERAL("text/xml"), FILE_PATH_LITERAL("xml") },
{ FILE_PATH_LITERAL("application/xhtml+xml"), FILE_PATH_LITERAL("xhtml") },
{ FILE_PATH_LITERAL("text/plain"), FILE_PATH_LITERAL("txt") },
{ FILE_PATH_LITERAL("text/css"), FILE_PATH_LITERAL("css") },
};
#if defined(OS_POSIX)
FilePath::StringType mime_type(contents_mime_type);
#elif defined(OS_WIN)
FilePath::StringType mime_type(UTF8ToWide(contents_mime_type));
#endif // OS_WIN
for (uint32 i = 0; i < ARRAYSIZE_UNSAFE(extensions); ++i) {
if (mime_type == extensions[i].mime_type)
return extensions[i].suggested_extension;
}
return FILE_PATH_LITERAL("");
}
| 1,545 |
145,753 | 0 | void ModuleSystem::SetLazyField(v8::Local<v8::Object> object,
const std::string& field,
const std::string& module_name,
const std::string& module_field) {
SetLazyField(
object, field, module_name, module_field, &ModuleSystem::LazyFieldGetter);
}
| 1,546 |
63,970 | 0 | void idct_mb(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3], VP8Macroblock *mb)
{
int x, y, ch;
if (mb->mode != MODE_I4x4) {
uint8_t *y_dst = dst[0];
for (y = 0; y < 4; y++) {
uint32_t nnz4 = AV_RL32(td->non_zero_count_cache[y]);
if (nnz4) {
if (nnz4 & ~0x01010101) {
for (x = 0; x < 4; x++) {
if ((uint8_t) nnz4 == 1)
s->vp8dsp.vp8_idct_dc_add(y_dst + 4 * x,
td->block[y][x],
s->linesize);
else if ((uint8_t) nnz4 > 1)
s->vp8dsp.vp8_idct_add(y_dst + 4 * x,
td->block[y][x],
s->linesize);
nnz4 >>= 8;
if (!nnz4)
break;
}
} else {
s->vp8dsp.vp8_idct_dc_add4y(y_dst, td->block[y], s->linesize);
}
}
y_dst += 4 * s->linesize;
}
}
for (ch = 0; ch < 2; ch++) {
uint32_t nnz4 = AV_RL32(td->non_zero_count_cache[4 + ch]);
if (nnz4) {
uint8_t *ch_dst = dst[1 + ch];
if (nnz4 & ~0x01010101) {
for (y = 0; y < 2; y++) {
for (x = 0; x < 2; x++) {
if ((uint8_t) nnz4 == 1)
s->vp8dsp.vp8_idct_dc_add(ch_dst + 4 * x,
td->block[4 + ch][(y << 1) + x],
s->uvlinesize);
else if ((uint8_t) nnz4 > 1)
s->vp8dsp.vp8_idct_add(ch_dst + 4 * x,
td->block[4 + ch][(y << 1) + x],
s->uvlinesize);
nnz4 >>= 8;
if (!nnz4)
goto chroma_idct_end;
}
ch_dst += 4 * s->uvlinesize;
}
} else {
s->vp8dsp.vp8_idct_dc_add4uv(ch_dst, td->block[4 + ch], s->uvlinesize);
}
}
chroma_idct_end:
;
}
}
| 1,547 |
29,359 | 0 | int kvm_vm_ioctl_set_memory_region(struct kvm *kvm,
struct kvm_userspace_memory_region *mem)
{
if (mem->slot >= KVM_USER_MEM_SLOTS)
return -EINVAL;
return kvm_set_memory_region(kvm, mem);
}
| 1,548 |
18,236 | 0 | static void complete_update_bin(conn *c) {
protocol_binary_response_status eno = PROTOCOL_BINARY_RESPONSE_EINVAL;
enum store_item_type ret = NOT_STORED;
assert(c != NULL);
item *it = c->item;
pthread_mutex_lock(&c->thread->stats.mutex);
c->thread->stats.slab_stats[it->slabs_clsid].set_cmds++;
pthread_mutex_unlock(&c->thread->stats.mutex);
/* We don't actually receive the trailing two characters in the bin
* protocol, so we're going to just set them here */
*(ITEM_data(it) + it->nbytes - 2) = '\r';
*(ITEM_data(it) + it->nbytes - 1) = '\n';
ret = store_item(it, c->cmd, c);
#ifdef ENABLE_DTRACE
uint64_t cas = ITEM_get_cas(it);
switch (c->cmd) {
case NREAD_ADD:
MEMCACHED_COMMAND_ADD(c->sfd, ITEM_key(it), it->nkey,
(ret == STORED) ? it->nbytes : -1, cas);
break;
case NREAD_REPLACE:
MEMCACHED_COMMAND_REPLACE(c->sfd, ITEM_key(it), it->nkey,
(ret == STORED) ? it->nbytes : -1, cas);
break;
case NREAD_APPEND:
MEMCACHED_COMMAND_APPEND(c->sfd, ITEM_key(it), it->nkey,
(ret == STORED) ? it->nbytes : -1, cas);
break;
case NREAD_PREPEND:
MEMCACHED_COMMAND_PREPEND(c->sfd, ITEM_key(it), it->nkey,
(ret == STORED) ? it->nbytes : -1, cas);
break;
case NREAD_SET:
MEMCACHED_COMMAND_SET(c->sfd, ITEM_key(it), it->nkey,
(ret == STORED) ? it->nbytes : -1, cas);
break;
}
#endif
switch (ret) {
case STORED:
/* Stored */
write_bin_response(c, NULL, 0, 0, 0);
break;
case EXISTS:
write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS, 0);
break;
case NOT_FOUND:
write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0);
break;
case NOT_STORED:
if (c->cmd == NREAD_ADD) {
eno = PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS;
} else if(c->cmd == NREAD_REPLACE) {
eno = PROTOCOL_BINARY_RESPONSE_KEY_ENOENT;
} else {
eno = PROTOCOL_BINARY_RESPONSE_NOT_STORED;
}
write_bin_error(c, eno, 0);
}
item_remove(c->item); /* release the c->item reference */
c->item = 0;
}
| 1,549 |
184,780 | 1 | static v8::Handle<v8::Value> methodWithCallbackArgCallback(const v8::Arguments& args)
{
INC_STATS("DOM.TestObj.methodWithCallbackArg");
if (args.Length() < 1)
return V8Proxy::throwNotEnoughArgumentsError();
TestObj* imp = V8TestObj::toNative(args.Holder());
if (args.Length() <= 0 || !args[0]->IsFunction())
return throwError(TYPE_MISMATCH_ERR, args.GetIsolate());
RefPtr<TestCallback> callback = V8TestCallback::create(args[0], getScriptExecutionContext());
imp->methodWithCallbackArg(callback);
return v8::Handle<v8::Value>();
}
| 1,550 |
138,532 | 0 | WorkerThread::~WorkerThread()
{
MutexLocker lock(threadSetMutex());
ASSERT(workerThreads().contains(this));
workerThreads().remove(this);
}
| 1,551 |
68,946 | 0 | slab_out_of_memory(struct kmem_cache *cachep, gfp_t gfpflags, int nodeid)
{
#if DEBUG
struct kmem_cache_node *n;
unsigned long flags;
int node;
static DEFINE_RATELIMIT_STATE(slab_oom_rs, DEFAULT_RATELIMIT_INTERVAL,
DEFAULT_RATELIMIT_BURST);
if ((gfpflags & __GFP_NOWARN) || !__ratelimit(&slab_oom_rs))
return;
pr_warn("SLAB: Unable to allocate memory on node %d, gfp=%#x(%pGg)\n",
nodeid, gfpflags, &gfpflags);
pr_warn(" cache: %s, object size: %d, order: %d\n",
cachep->name, cachep->size, cachep->gfporder);
for_each_kmem_cache_node(cachep, node, n) {
unsigned long total_slabs, free_slabs, free_objs;
spin_lock_irqsave(&n->list_lock, flags);
total_slabs = n->total_slabs;
free_slabs = n->free_slabs;
free_objs = n->free_objects;
spin_unlock_irqrestore(&n->list_lock, flags);
pr_warn(" node %d: slabs: %ld/%ld, objs: %ld/%ld\n",
node, total_slabs - free_slabs, total_slabs,
(total_slabs * cachep->num) - free_objs,
total_slabs * cachep->num);
}
#endif
}
| 1,552 |
148,942 | 0 | static void TRACE_IDX_OUTPUTS(sqlite3_index_info *p){
int i;
if( !sqlite3WhereTrace ) return;
for(i=0; i<p->nConstraint; i++){
sqlite3DebugPrintf(" usage[%d]: argvIdx=%d omit=%d\n",
i,
p->aConstraintUsage[i].argvIndex,
p->aConstraintUsage[i].omit);
}
sqlite3DebugPrintf(" idxNum=%d\n", p->idxNum);
sqlite3DebugPrintf(" idxStr=%s\n", p->idxStr);
sqlite3DebugPrintf(" orderByConsumed=%d\n", p->orderByConsumed);
sqlite3DebugPrintf(" estimatedCost=%g\n", p->estimatedCost);
sqlite3DebugPrintf(" estimatedRows=%lld\n", p->estimatedRows);
}
| 1,553 |
8,157 | 0 | void Gfx::opSetStrokeColor(Object args[], int numArgs) {
GfxColor color;
int i;
if (numArgs != state->getStrokeColorSpace()->getNComps()) {
error(getPos(), "Incorrect number of arguments in 'SC' command");
return;
}
state->setStrokePattern(NULL);
for (i = 0; i < numArgs; ++i) {
color.c[i] = dblToCol(args[i].getNum());
}
state->setStrokeColor(&color);
out->updateStrokeColor(state);
}
| 1,554 |
86,459 | 0 | static struct file *userfaultfd_file_create(int flags)
{
struct file *file;
struct userfaultfd_ctx *ctx;
BUG_ON(!current->mm);
/* Check the UFFD_* constants for consistency. */
BUILD_BUG_ON(UFFD_CLOEXEC != O_CLOEXEC);
BUILD_BUG_ON(UFFD_NONBLOCK != O_NONBLOCK);
file = ERR_PTR(-EINVAL);
if (flags & ~UFFD_SHARED_FCNTL_FLAGS)
goto out;
file = ERR_PTR(-ENOMEM);
ctx = kmem_cache_alloc(userfaultfd_ctx_cachep, GFP_KERNEL);
if (!ctx)
goto out;
atomic_set(&ctx->refcount, 1);
ctx->flags = flags;
ctx->features = 0;
ctx->state = UFFD_STATE_WAIT_API;
ctx->released = false;
ctx->mm = current->mm;
/* prevent the mm struct to be freed */
mmgrab(ctx->mm);
file = anon_inode_getfile("[userfaultfd]", &userfaultfd_fops, ctx,
O_RDWR | (flags & UFFD_SHARED_FCNTL_FLAGS));
if (IS_ERR(file)) {
mmdrop(ctx->mm);
kmem_cache_free(userfaultfd_ctx_cachep, ctx);
}
out:
return file;
}
| 1,555 |
162,790 | 0 | void ContextState::EnableDisable(GLenum pname, bool enable) const {
if (pname == GL_PRIMITIVE_RESTART_FIXED_INDEX &&
feature_info_->feature_flags().emulate_primitive_restart_fixed_index) {
return;
}
if (enable) {
api()->glEnableFn(pname);
} else {
api()->glDisableFn(pname);
}
}
| 1,556 |
101,196 | 0 | int64 BuildCommitCommand::GetGap() {
return 1LL << 20;
}
| 1,557 |
174,738 | 0 | void WT_ProcessVoice (S_WT_VOICE *pWTVoice, S_WT_INT_FRAME *pWTIntFrame)
{
/* use noise generator */
if (pWTVoice->loopStart == WT_NOISE_GENERATOR)
WT_NoiseGenerator(pWTVoice, pWTIntFrame);
/* generate interpolated samples for looped waves */
else if (pWTVoice->loopStart != pWTVoice->loopEnd)
WT_Interpolate(pWTVoice, pWTIntFrame);
/* generate interpolated samples for unlooped waves */
else
{
WT_InterpolateNoLoop(pWTVoice, pWTIntFrame);
}
#ifdef _FILTER_ENABLED
if (pWTIntFrame->frame.k != 0)
WT_VoiceFilter(&pWTVoice->filter, pWTIntFrame);
#endif
#ifdef UNIFIED_MIXER
{
EAS_I32 gainLeft, gainIncLeft;
#if (NUM_OUTPUT_CHANNELS == 2)
EAS_I32 gainRight, gainIncRight;
#endif
gainLeft = (pWTIntFrame->prevGain * pWTVoice->gainLeft) << 1;
gainIncLeft = (((pWTIntFrame->frame.gainTarget * pWTVoice->gainLeft) << 1) - gainLeft) >> SYNTH_UPDATE_PERIOD_IN_BITS;
#if (NUM_OUTPUT_CHANNELS == 2)
gainRight = (pWTIntFrame->prevGain * pWTVoice->gainRight) << 1;
gainIncRight = (((pWTIntFrame->frame.gainTarget * pWTVoice->gainRight) << 1) - gainRight) >> SYNTH_UPDATE_PERIOD_IN_BITS;
EAS_MixStream(
pWTIntFrame->pAudioBuffer,
pWTIntFrame->pMixBuffer,
pWTIntFrame->numSamples,
gainLeft,
gainRight,
gainIncLeft,
gainIncRight,
MIX_FLAGS_STEREO_OUTPUT);
#else
EAS_MixStream(
pWTIntFrame->pAudioBuffer,
pWTIntFrame->pMixBuffer,
pWTIntFrame->numSamples,
gainLeft,
0,
gainIncLeft,
0,
0);
#endif
}
#else
/* apply gain, and left and right gain */
WT_VoiceGain(pWTVoice, pWTIntFrame);
#endif
}
| 1,558 |
36,574 | 0 | void cgtime(struct timeval *tv)
{
lldiv_t lidiv;
decius_time(&lidiv);
tv->tv_sec = lidiv.quot;
tv->tv_usec = lidiv.rem / 10;
}
| 1,559 |
125,822 | 0 | void ParamTraits<unsigned short>::Write(Message* m, const param_type& p) {
m->WriteBytes(&p, sizeof(param_type));
}
| 1,560 |
32,009 | 0 | generate_key_random (struct key *key, const struct key_type *kt)
{
int cipher_len = MAX_CIPHER_KEY_LENGTH;
int hmac_len = MAX_HMAC_KEY_LENGTH;
struct gc_arena gc = gc_new ();
do {
CLEAR (*key);
if (kt)
{
if (kt->cipher && kt->cipher_length > 0 && kt->cipher_length <= cipher_len)
cipher_len = kt->cipher_length;
if (kt->digest && kt->hmac_length > 0 && kt->hmac_length <= hmac_len)
hmac_len = kt->hmac_length;
}
if (!rand_bytes (key->cipher, cipher_len)
|| !rand_bytes (key->hmac, hmac_len))
msg (M_FATAL, "ERROR: Random number generator cannot obtain entropy for key generation");
dmsg (D_SHOW_KEY_SOURCE, "Cipher source entropy: %s", format_hex (key->cipher, cipher_len, 0, &gc));
dmsg (D_SHOW_KEY_SOURCE, "HMAC source entropy: %s", format_hex (key->hmac, hmac_len, 0, &gc));
if (kt)
fixup_key (key, kt);
} while (kt && !check_key (key, kt));
gc_free (&gc);
}
| 1,561 |
38,422 | 0 | static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
char *buf)
{
struct cm_counter_group *group;
struct cm_counter_attribute *cm_attr;
group = container_of(obj, struct cm_counter_group, obj);
cm_attr = container_of(attr, struct cm_counter_attribute, attr);
return sprintf(buf, "%ld\n",
atomic_long_read(&group->counter[cm_attr->index]));
}
| 1,562 |
48,270 | 0 | void process_command_opts (int argc, char *argv[], char *mp, char *mode, uint32 *dirnum,
uint16 *defconfig, uint16 *deffillorder, uint32 *deftilewidth,
uint32 *deftilelength, uint32 *defrowsperstrip,
struct crop_mask *crop_data, struct pagedef *page,
struct dump_opts *dump,
unsigned int *imagelist, unsigned int *image_count )
{
int c, good_args = 0;
char *opt_offset = NULL; /* Position in string of value sought */
char *opt_ptr = NULL; /* Pointer to next token in option set */
char *sep = NULL; /* Pointer to a token separator */
unsigned int i, j, start, end;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char* optarg;
#endif
*mp++ = 'w';
*mp = '\0';
while ((c = getopt(argc, argv,
"ac:d:e:f:hil:m:p:r:stvw:z:BCD:E:F:H:I:J:K:LMN:O:P:R:S:U:V:X:Y:Z:")) != -1)
{
good_args++;
switch (c) {
case 'a': mode[0] = 'a'; /* append to output */
break;
case 'c': if (!processCompressOptions(optarg)) /* compression scheme */
{
TIFFError ("Unknown compression option", "%s", optarg);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
break;
case 'd': start = strtoul(optarg, NULL, 0); /* initial IFD offset */
if (start == 0)
{
TIFFError ("","Directory offset must be greater than zero");
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
*dirnum = start - 1;
break;
case 'e': switch (tolower((int) optarg[0])) /* image export modes*/
{
case 'c': crop_data->exp_mode = ONE_FILE_COMPOSITE;
crop_data->img_mode = COMPOSITE_IMAGES;
break; /* Composite */
case 'd': crop_data->exp_mode = ONE_FILE_SEPARATED;
crop_data->img_mode = SEPARATED_IMAGES;
break; /* Divided */
case 'i': crop_data->exp_mode = FILE_PER_IMAGE_COMPOSITE;
crop_data->img_mode = COMPOSITE_IMAGES;
break; /* Image */
case 'm': crop_data->exp_mode = FILE_PER_IMAGE_SEPARATED;
crop_data->img_mode = SEPARATED_IMAGES;
break; /* Multiple */
case 's': crop_data->exp_mode = FILE_PER_SELECTION;
crop_data->img_mode = SEPARATED_IMAGES;
break; /* Sections */
default: TIFFError ("Unknown export mode","%s", optarg);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
break;
case 'f': if (streq(optarg, "lsb2msb")) /* fill order */
*deffillorder = FILLORDER_LSB2MSB;
else if (streq(optarg, "msb2lsb"))
*deffillorder = FILLORDER_MSB2LSB;
else
{
TIFFError ("Unknown fill order", "%s", optarg);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
break;
case 'h': usage();
break;
case 'i': ignore = TRUE; /* ignore errors */
break;
case 'l': outtiled = TRUE; /* tile length */
*deftilelength = atoi(optarg);
break;
case 'p': /* planar configuration */
if (streq(optarg, "separate"))
*defconfig = PLANARCONFIG_SEPARATE;
else if (streq(optarg, "contig"))
*defconfig = PLANARCONFIG_CONTIG;
else
{
TIFFError ("Unkown planar configuration", "%s", optarg);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
break;
case 'r': /* rows/strip */
*defrowsperstrip = atol(optarg);
break;
case 's': /* generate stripped output */
outtiled = FALSE;
break;
case 't': /* generate tiled output */
outtiled = TRUE;
break;
case 'v': TIFFError("Library Release", "%s", TIFFGetVersion());
TIFFError ("Tiffcrop version", "%s, last updated: %s",
tiffcrop_version_id, tiffcrop_rev_date);
TIFFError ("Tiffcp code", "Copyright (c) 1988-1997 Sam Leffler");
TIFFError (" ", "Copyright (c) 1991-1997 Silicon Graphics, Inc");
TIFFError ("Tiffcrop additions", "Copyright (c) 2007-2010 Richard Nolde");
exit (0);
break;
case 'w': /* tile width */
outtiled = TRUE;
*deftilewidth = atoi(optarg);
break;
case 'z': /* regions of an image specified as x1,y1,x2,y2:x3,y3,x4,y4 etc */
crop_data->crop_mode |= CROP_REGIONS;
for (i = 0, opt_ptr = strtok (optarg, ":");
((opt_ptr != NULL) && (i < MAX_REGIONS));
(opt_ptr = strtok (NULL, ":")), i++)
{
crop_data->regions++;
if (sscanf(opt_ptr, "%lf,%lf,%lf,%lf",
&crop_data->corners[i].X1, &crop_data->corners[i].Y1,
&crop_data->corners[i].X2, &crop_data->corners[i].Y2) != 4)
{
TIFFError ("Unable to parse coordinates for region", "%d %s", i, optarg);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
}
/* check for remaining elements over MAX_REGIONS */
if ((opt_ptr != NULL) && (i >= MAX_REGIONS))
{
TIFFError ("Region list exceeds limit of", "%d regions %s", MAX_REGIONS, optarg);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);;
}
break;
/* options for file open modes */
case 'B': *mp++ = 'b'; *mp = '\0';
break;
case 'L': *mp++ = 'l'; *mp = '\0';
break;
case 'M': *mp++ = 'm'; *mp = '\0';
break;
case 'C': *mp++ = 'c'; *mp = '\0';
break;
/* options for Debugging / data dump */
case 'D': for (i = 0, opt_ptr = strtok (optarg, ",");
(opt_ptr != NULL);
(opt_ptr = strtok (NULL, ",")), i++)
{
opt_offset = strpbrk(opt_ptr, ":=");
if (opt_offset == NULL)
{
TIFFError("Invalid dump option", "%s", optarg);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
*opt_offset = '\0';
/* convert option to lowercase */
end = strlen (opt_ptr);
for (i = 0; i < end; i++)
*(opt_ptr + i) = tolower((int) *(opt_ptr + i));
/* Look for dump format specification */
if (strncmp(opt_ptr, "for", 3) == 0)
{
/* convert value to lowercase */
end = strlen (opt_offset + 1);
for (i = 1; i <= end; i++)
*(opt_offset + i) = tolower((int) *(opt_offset + i));
/* check dump format value */
if (strncmp (opt_offset + 1, "txt", 3) == 0)
{
dump->format = DUMP_TEXT;
strcpy (dump->mode, "w");
}
else
{
if (strncmp(opt_offset + 1, "raw", 3) == 0)
{
dump->format = DUMP_RAW;
strcpy (dump->mode, "wb");
}
else
{
TIFFError("parse_command_opts", "Unknown dump format %s", opt_offset + 1);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
}
}
else
{ /* Look for dump level specification */
if (strncmp (opt_ptr, "lev", 3) == 0)
dump->level = atoi(opt_offset + 1);
/* Look for input data dump file name */
if (strncmp (opt_ptr, "in", 2) == 0)
{
strncpy (dump->infilename, opt_offset + 1, PATH_MAX - 20);
dump->infilename[PATH_MAX - 20] = '\0';
}
/* Look for output data dump file name */
if (strncmp (opt_ptr, "out", 3) == 0)
{
strncpy (dump->outfilename, opt_offset + 1, PATH_MAX - 20);
dump->outfilename[PATH_MAX - 20] = '\0';
}
if (strncmp (opt_ptr, "deb", 3) == 0)
dump->debug = atoi(opt_offset + 1);
}
}
if ((strlen(dump->infilename)) || (strlen(dump->outfilename)))
{
if (dump->level == 1)
TIFFError("","Defaulting to dump level 1, no data.");
if (dump->format == DUMP_NONE)
{
TIFFError("", "You must specify a dump format for dump files");
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
}
break;
/* image manipulation routine options */
case 'm': /* margins to exclude from selection, uppercase M was already used */
/* order of values must be TOP, LEFT, BOTTOM, RIGHT */
crop_data->crop_mode |= CROP_MARGINS;
for (i = 0, opt_ptr = strtok (optarg, ",:");
((opt_ptr != NULL) && (i < 4));
(opt_ptr = strtok (NULL, ",:")), i++)
{
crop_data->margins[i] = atof(opt_ptr);
}
break;
case 'E': /* edge reference */
switch (tolower((int) optarg[0]))
{
case 't': crop_data->edge_ref = EDGE_TOP;
break;
case 'b': crop_data->edge_ref = EDGE_BOTTOM;
break;
case 'l': crop_data->edge_ref = EDGE_LEFT;
break;
case 'r': crop_data->edge_ref = EDGE_RIGHT;
break;
default: TIFFError ("Edge reference must be top, bottom, left, or right", "%s", optarg);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
break;
case 'F': /* flip eg mirror image or cropped segment, M was already used */
crop_data->crop_mode |= CROP_MIRROR;
switch (tolower((int) optarg[0]))
{
case 'h': crop_data->mirror = MIRROR_HORIZ;
break;
case 'v': crop_data->mirror = MIRROR_VERT;
break;
case 'b': crop_data->mirror = MIRROR_BOTH;
break;
default: TIFFError ("Flip mode must be horiz, vert, or both", "%s", optarg);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
break;
case 'H': /* set horizontal resolution to new value */
page->hres = atof (optarg);
page->mode |= PAGE_MODE_RESOLUTION;
break;
case 'I': /* invert the color space, eg black to white */
crop_data->crop_mode |= CROP_INVERT;
/* The PHOTOMETIC_INTERPRETATION tag may be updated */
if (streq(optarg, "black"))
{
crop_data->photometric = PHOTOMETRIC_MINISBLACK;
continue;
}
if (streq(optarg, "white"))
{
crop_data->photometric = PHOTOMETRIC_MINISWHITE;
continue;
}
if (streq(optarg, "data"))
{
crop_data->photometric = INVERT_DATA_ONLY;
continue;
}
if (streq(optarg, "both"))
{
crop_data->photometric = INVERT_DATA_AND_TAG;
continue;
}
TIFFError("Missing or unknown option for inverting PHOTOMETRIC_INTERPRETATION", "%s", optarg);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
break;
case 'J': /* horizontal margin for sectioned ouput pages */
page->hmargin = atof(optarg);
page->mode |= PAGE_MODE_MARGINS;
break;
case 'K': /* vertical margin for sectioned ouput pages*/
page->vmargin = atof(optarg);
page->mode |= PAGE_MODE_MARGINS;
break;
case 'N': /* list of images to process */
for (i = 0, opt_ptr = strtok (optarg, ",");
((opt_ptr != NULL) && (i < MAX_IMAGES));
(opt_ptr = strtok (NULL, ",")))
{ /* We do not know how many images are in file yet
* so we build a list to include the maximum allowed
* and follow it until we hit the end of the file.
* Image count is not accurate for odd, even, last
* so page numbers won't be valid either.
*/
if (streq(opt_ptr, "odd"))
{
for (j = 1; j <= MAX_IMAGES; j += 2)
imagelist[i++] = j;
*image_count = (MAX_IMAGES - 1) / 2;
break;
}
else
{
if (streq(opt_ptr, "even"))
{
for (j = 2; j <= MAX_IMAGES; j += 2)
imagelist[i++] = j;
*image_count = MAX_IMAGES / 2;
break;
}
else
{
if (streq(opt_ptr, "last"))
imagelist[i++] = MAX_IMAGES;
else /* single value between commas */
{
sep = strpbrk(opt_ptr, ":-");
if (!sep)
imagelist[i++] = atoi(opt_ptr);
else
{
*sep = '\0';
start = atoi (opt_ptr);
if (!strcmp((sep + 1), "last"))
end = MAX_IMAGES;
else
end = atoi (sep + 1);
for (j = start; j <= end && j - start + i < MAX_IMAGES; j++)
imagelist[i++] = j;
}
}
}
}
}
*image_count = i;
break;
case 'O': /* page orientation */
switch (tolower((int) optarg[0]))
{
case 'a': page->orient = ORIENTATION_AUTO;
break;
case 'p': page->orient = ORIENTATION_PORTRAIT;
break;
case 'l': page->orient = ORIENTATION_LANDSCAPE;
break;
default: TIFFError ("Orientation must be portrait, landscape, or auto.", "%s", optarg);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
break;
case 'P': /* page size selection */
if (sscanf(optarg, "%lfx%lf", &page->width, &page->length) == 2)
{
strcpy (page->name, "Custom");
page->mode |= PAGE_MODE_PAPERSIZE;
break;
}
if (get_page_geometry (optarg, page))
{
if (!strcmp(optarg, "list"))
{
TIFFError("", "Name Width Length (in inches)");
for (i = 0; i < MAX_PAPERNAMES - 1; i++)
TIFFError ("", "%-15.15s %5.2f %5.2f",
PaperTable[i].name, PaperTable[i].width,
PaperTable[i].length);
exit (-1);
}
TIFFError ("Invalid paper size", "%s", optarg);
TIFFError ("", "Select one of:");
TIFFError("", "Name Width Length (in inches)");
for (i = 0; i < MAX_PAPERNAMES - 1; i++)
TIFFError ("", "%-15.15s %5.2f %5.2f",
PaperTable[i].name, PaperTable[i].width,
PaperTable[i].length);
exit (-1);
}
else
{
page->mode |= PAGE_MODE_PAPERSIZE;
}
break;
case 'R': /* rotate image or cropped segment */
crop_data->crop_mode |= CROP_ROTATE;
switch (strtoul(optarg, NULL, 0))
{
case 90: crop_data->rotation = (uint16)90;
break;
case 180: crop_data->rotation = (uint16)180;
break;
case 270: crop_data->rotation = (uint16)270;
break;
default: TIFFError ("Rotation must be 90, 180, or 270 degrees clockwise", "%s", optarg);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
break;
case 'S': /* subdivide into Cols:Rows sections, eg 3:2 would be 3 across and 2 down */
sep = strpbrk(optarg, ",:");
if (sep)
{
*sep = '\0';
page->cols = atoi(optarg);
page->rows = atoi(sep +1);
}
else
{
page->cols = atoi(optarg);
page->rows = atoi(optarg);
}
if ((page->cols * page->rows) > MAX_SECTIONS)
{
TIFFError ("Limit for subdivisions, ie rows x columns, exceeded", "%d", MAX_SECTIONS);
exit (-1);
}
page->mode |= PAGE_MODE_ROWSCOLS;
break;
case 'U': /* units for measurements and offsets */
if (streq(optarg, "in"))
{
crop_data->res_unit = RESUNIT_INCH;
page->res_unit = RESUNIT_INCH;
}
else if (streq(optarg, "cm"))
{
crop_data->res_unit = RESUNIT_CENTIMETER;
page->res_unit = RESUNIT_CENTIMETER;
}
else if (streq(optarg, "px"))
{
crop_data->res_unit = RESUNIT_NONE;
page->res_unit = RESUNIT_NONE;
}
else
{
TIFFError ("Illegal unit of measure","%s", optarg);
TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
}
break;
case 'V': /* set vertical resolution to new value */
page->vres = atof (optarg);
page->mode |= PAGE_MODE_RESOLUTION;
break;
case 'X': /* selection width */
crop_data->crop_mode |= CROP_WIDTH;
crop_data->width = atof(optarg);
break;
case 'Y': /* selection length */
crop_data->crop_mode |= CROP_LENGTH;
crop_data->length = atof(optarg);
break;
case 'Z': /* zones of an image X:Y read as zone X of Y */
crop_data->crop_mode |= CROP_ZONES;
for (i = 0, opt_ptr = strtok (optarg, ",");
((opt_ptr != NULL) && (i < MAX_REGIONS));
(opt_ptr = strtok (NULL, ",")), i++)
{
crop_data->zones++;
opt_offset = strchr(opt_ptr, ':');
if (!opt_offset) {
TIFFError("Wrong parameter syntax for -Z", "tiffcrop -h");
exit(-1);
}
*opt_offset = '\0';
crop_data->zonelist[i].position = atoi(opt_ptr);
crop_data->zonelist[i].total = atoi(opt_offset + 1);
}
/* check for remaining elements over MAX_REGIONS */
if ((opt_ptr != NULL) && (i >= MAX_REGIONS))
{
TIFFError("Zone list exceeds region limit", "%d", MAX_REGIONS);
exit (-1);
}
break;
case '?': TIFFError ("For valid options type", "tiffcrop -h");
exit (-1);
/*NOTREACHED*/
}
}
} /* end process_command_opts */
| 1,563 |
57,551 | 0 | static handle_t *start_transaction(struct inode *inode)
{
handle_t *result;
result = ext4_journal_start(inode, blocks_for_truncate(inode));
if (!IS_ERR(result))
return result;
ext4_std_error(inode->i_sb, PTR_ERR(result));
return result;
}
| 1,564 |
153,431 | 0 | bool IsStackingDraggedTabs() const {
return drag_controller_.get() && drag_controller_->started_drag() &&
(drag_controller_->move_behavior() ==
TabDragController::MOVE_VISIBLE_TABS);
}
| 1,565 |
54,394 | 0 | static ZIPARCHIVE_METHOD(statIndex)
{
struct zip *intern;
zval *self = getThis();
zend_long index, flags = 0;
struct zip_stat sb;
if (!self) {
RETURN_FALSE;
}
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l",
&index, &flags) == FAILURE) {
return;
}
if (zip_stat_index(intern, index, flags, &sb) != 0) {
RETURN_FALSE;
}
RETURN_SB(&sb);
}
| 1,566 |
178,441 | 1 | int __glXDispSwap_CreateContext(__GLXclientState *cl, GLbyte *pc)
{
xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->context);
__GLX_SWAP_INT(&req->visual);
return __glXDisp_CreateContext(cl, pc);
}
| 1,567 |
75,561 | 0 | int usb_get_current_frame_number(struct usb_device *dev)
{
return usb_hcd_get_frame_number(dev);
}
| 1,568 |
62,273 | 0 | fs_reply_print(netdissect_options *ndo,
register const u_char *bp, int length, int32_t opcode)
{
unsigned long i;
const struct rx_header *rxh;
if (length <= (int)sizeof(struct rx_header))
return;
rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
* gleaned from fsint/afsint.xg
*/
ND_PRINT((ndo, " fs reply %s", tok2str(fs_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
/*
* If it was a data packet, interpret the response
*/
if (rxh->type == RX_PACKET_TYPE_DATA) {
switch (opcode) {
case 131: /* Fetch ACL */
{
char a[AFSOPAQUEMAX+1];
ND_TCHECK2(bp[0], 4);
i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
ND_TCHECK2(bp[0], i);
i = min(AFSOPAQUEMAX, i);
strncpy(a, (const char *) bp, i);
a[i] = '\0';
acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i);
break;
}
case 137: /* Create file */
case 141: /* MakeDir */
ND_PRINT((ndo, " new"));
FIDOUT();
break;
case 151: /* Get root volume */
ND_PRINT((ndo, " root volume"));
STROUT(AFSNAMEMAX);
break;
case 153: /* Get time */
DATEOUT();
break;
default:
;
}
} else if (rxh->type == RX_PACKET_TYPE_ABORT) {
/*
* Otherwise, just print out the return code
*/
ND_TCHECK2(bp[0], sizeof(int32_t));
i = (int) EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
ND_PRINT((ndo, " error %s", tok2str(afs_fs_errors, "#%d", i)));
} else {
ND_PRINT((ndo, " strange fs reply of type %d", rxh->type));
}
return;
trunc:
ND_PRINT((ndo, " [|fs]"));
}
| 1,569 |
68,408 | 0 | static void perf_remove_from_owner(struct perf_event *event)
{
struct task_struct *owner;
rcu_read_lock();
/*
* Matches the smp_store_release() in perf_event_exit_task(). If we
* observe !owner it means the list deletion is complete and we can
* indeed free this event, otherwise we need to serialize on
* owner->perf_event_mutex.
*/
owner = lockless_dereference(event->owner);
if (owner) {
/*
* Since delayed_put_task_struct() also drops the last
* task reference we can safely take a new reference
* while holding the rcu_read_lock().
*/
get_task_struct(owner);
}
rcu_read_unlock();
if (owner) {
/*
* If we're here through perf_event_exit_task() we're already
* holding ctx->mutex which would be an inversion wrt. the
* normal lock order.
*
* However we can safely take this lock because its the child
* ctx->mutex.
*/
mutex_lock_nested(&owner->perf_event_mutex, SINGLE_DEPTH_NESTING);
/*
* We have to re-check the event->owner field, if it is cleared
* we raced with perf_event_exit_task(), acquiring the mutex
* ensured they're done, and we can proceed with freeing the
* event.
*/
if (event->owner) {
list_del_init(&event->owner_entry);
smp_store_release(&event->owner, NULL);
}
mutex_unlock(&owner->perf_event_mutex);
put_task_struct(owner);
}
}
| 1,570 |
71,836 | 0 | static void ipa_region_paint(wmfAPI * API, wmfPolyRectangle_t * poly_rect)
{
if (poly_rect->count == 0)
return;
/* Save graphic wand */
(void) PushDrawingWand(WmfDrawingWand);
if (TO_FILL (poly_rect))
{
long
i;
draw_stroke_color_string(WmfDrawingWand,"none");
util_set_brush(API, poly_rect->dc, BrushApplyFill);
for (i = 0; i < (long) poly_rect->count; i++)
{
DrawRectangle(WmfDrawingWand,
XC(poly_rect->TL[i].x), YC(poly_rect->TL[i].y),
XC(poly_rect->BR[i].x), YC(poly_rect->BR[i].y));
}
}
/* Restore graphic wand */
(void) PopDrawingWand(WmfDrawingWand);
}
| 1,571 |
113,938 | 0 | void RegistrationManager::RegistrationStatus::DoRegister() {
CHECK(enabled);
registration_timer.Stop();
delay = base::TimeDelta();
registration_manager->DoRegisterId(id);
DCHECK(!last_registration_request.is_null());
}
| 1,572 |
13,226 | 0 | processLog_trace(const boost::format& /* fmt */)
{ /* do nothing */ }
| 1,573 |
57,177 | 0 | static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
struct nfs4_state_owner *sp, fmode_t fmode, int flags,
const struct iattr *attrs,
struct nfs4_label *label,
enum open_claim_type4 claim,
gfp_t gfp_mask)
{
struct dentry *parent = dget_parent(dentry);
struct inode *dir = d_inode(parent);
struct nfs_server *server = NFS_SERVER(dir);
struct nfs_seqid *(*alloc_seqid)(struct nfs_seqid_counter *, gfp_t);
struct nfs4_opendata *p;
p = kzalloc(sizeof(*p), gfp_mask);
if (p == NULL)
goto err;
p->f_label = nfs4_label_alloc(server, gfp_mask);
if (IS_ERR(p->f_label))
goto err_free_p;
p->a_label = nfs4_label_alloc(server, gfp_mask);
if (IS_ERR(p->a_label))
goto err_free_f;
alloc_seqid = server->nfs_client->cl_mvops->alloc_seqid;
p->o_arg.seqid = alloc_seqid(&sp->so_seqid, gfp_mask);
if (IS_ERR(p->o_arg.seqid))
goto err_free_label;
nfs_sb_active(dentry->d_sb);
p->dentry = dget(dentry);
p->dir = parent;
p->owner = sp;
atomic_inc(&sp->so_count);
p->o_arg.open_flags = flags;
p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE);
p->o_arg.share_access = nfs4_map_atomic_open_share(server,
fmode, flags);
/* don't put an ACCESS op in OPEN compound if O_EXCL, because ACCESS
* will return permission denied for all bits until close */
if (!(flags & O_EXCL)) {
/* ask server to check for all possible rights as results
* are cached */
p->o_arg.access = NFS4_ACCESS_READ | NFS4_ACCESS_MODIFY |
NFS4_ACCESS_EXTEND | NFS4_ACCESS_EXECUTE;
}
p->o_arg.clientid = server->nfs_client->cl_clientid;
p->o_arg.id.create_time = ktime_to_ns(sp->so_seqid.create_time);
p->o_arg.id.uniquifier = sp->so_seqid.owner_id;
p->o_arg.name = &dentry->d_name;
p->o_arg.server = server;
p->o_arg.bitmask = nfs4_bitmask(server, label);
p->o_arg.open_bitmap = &nfs4_fattr_bitmap[0];
p->o_arg.label = nfs4_label_copy(p->a_label, label);
p->o_arg.claim = nfs4_map_atomic_open_claim(server, claim);
switch (p->o_arg.claim) {
case NFS4_OPEN_CLAIM_NULL:
case NFS4_OPEN_CLAIM_DELEGATE_CUR:
case NFS4_OPEN_CLAIM_DELEGATE_PREV:
p->o_arg.fh = NFS_FH(dir);
break;
case NFS4_OPEN_CLAIM_PREVIOUS:
case NFS4_OPEN_CLAIM_FH:
case NFS4_OPEN_CLAIM_DELEG_CUR_FH:
case NFS4_OPEN_CLAIM_DELEG_PREV_FH:
p->o_arg.fh = NFS_FH(d_inode(dentry));
}
if (attrs != NULL && attrs->ia_valid != 0) {
__u32 verf[2];
p->o_arg.u.attrs = &p->attrs;
memcpy(&p->attrs, attrs, sizeof(p->attrs));
verf[0] = jiffies;
verf[1] = current->pid;
memcpy(p->o_arg.u.verifier.data, verf,
sizeof(p->o_arg.u.verifier.data));
}
p->c_arg.fh = &p->o_res.fh;
p->c_arg.stateid = &p->o_res.stateid;
p->c_arg.seqid = p->o_arg.seqid;
nfs4_init_opendata_res(p);
kref_init(&p->kref);
return p;
err_free_label:
nfs4_label_free(p->a_label);
err_free_f:
nfs4_label_free(p->f_label);
err_free_p:
kfree(p);
err:
dput(parent);
return NULL;
}
| 1,574 |
79,587 | 0 | int imap_delete_mailbox(struct Context *ctx, struct ImapMbox *mx)
{
char buf[PATH_MAX], mbox[PATH_MAX];
struct ImapData *idata = NULL;
if (!ctx || !ctx->data)
{
idata = imap_conn_find(&mx->account, ImapPassive ? MUTT_IMAP_CONN_NONEW : 0);
if (!idata)
{
FREE(&mx->mbox);
return -1;
}
}
else
{
idata = ctx->data;
}
imap_munge_mbox_name(idata, mbox, sizeof(mbox), mx->mbox);
snprintf(buf, sizeof(buf), "DELETE %s", mbox);
if (imap_exec(idata, buf, 0) != 0)
return -1;
return 0;
}
| 1,575 |
114,321 | 0 | getTranslatedShaderSourceANGLE(WebGLId shader) {
GLint logLength = 0;
gl_->GetShaderiv(
shader, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, &logLength);
if (!logLength)
return WebKit::WebString();
scoped_array<GLchar> log(new GLchar[logLength]);
if (!log.get())
return WebKit::WebString();
GLsizei returnedLogLength = 0;
gl_->GetTranslatedShaderSourceANGLE(
shader, logLength, &returnedLogLength, log.get());
if (!returnedLogLength)
return WebKit::WebString();
DCHECK_EQ(logLength, returnedLogLength + 1);
WebKit::WebString res =
WebKit::WebString::fromUTF8(log.get(), returnedLogLength);
return res;
}
| 1,576 |
506 | 0 | static void pdf_run_Tw(fz_context *ctx, pdf_processor *proc, float wordspace)
{
pdf_run_processor *pr = (pdf_run_processor *)proc;
pdf_gstate *gstate = pr->gstate + pr->gtop;
gstate->text.word_space = wordspace;
}
| 1,577 |
126,551 | 0 | gboolean TabStripGtk::OnDragDrop(GtkWidget* widget, GdkDragContext* context,
gint x, gint y, guint time) {
if (!drop_info_.get())
return FALSE;
GdkAtom target = gtk_drag_dest_find_target(widget, context, NULL);
if (target != GDK_NONE)
gtk_drag_finish(context, FALSE, FALSE, time);
else
gtk_drag_get_data(widget, context, target, time);
return TRUE;
}
| 1,578 |
82,257 | 0 | static int do_sys_recvmmsg(int fd, struct mmsghdr __user *mmsg,
unsigned int vlen, unsigned int flags,
struct timespec __user *timeout)
{
int datagrams;
struct timespec timeout_sys;
if (flags & MSG_CMSG_COMPAT)
return -EINVAL;
if (!timeout)
return __sys_recvmmsg(fd, mmsg, vlen, flags, NULL);
if (copy_from_user(&timeout_sys, timeout, sizeof(timeout_sys)))
return -EFAULT;
datagrams = __sys_recvmmsg(fd, mmsg, vlen, flags, &timeout_sys);
if (datagrams > 0 &&
copy_to_user(timeout, &timeout_sys, sizeof(timeout_sys)))
datagrams = -EFAULT;
return datagrams;
}
| 1,579 |
47,095 | 0 | static void nx842_exit(struct crypto_tfm *tfm)
{
struct nx842_ctx *ctx = crypto_tfm_ctx(tfm);
kfree(ctx->nx842_wmem);
}
| 1,580 |
48,636 | 0 | static h2_session *h2_session_create_int(conn_rec *c,
request_rec *r,
h2_ctx *ctx,
h2_workers *workers)
{
nghttp2_session_callbacks *callbacks = NULL;
nghttp2_option *options = NULL;
uint32_t n;
apr_pool_t *pool = NULL;
apr_status_t status = apr_pool_create(&pool, c->pool);
h2_session *session;
if (status != APR_SUCCESS) {
return NULL;
}
apr_pool_tag(pool, "h2_session");
session = apr_pcalloc(pool, sizeof(h2_session));
if (session) {
int rv;
nghttp2_mem *mem;
session->id = c->id;
session->c = c;
session->r = r;
session->s = h2_ctx_server_get(ctx);
session->pool = pool;
session->config = h2_config_sget(session->s);
session->workers = workers;
session->state = H2_SESSION_ST_INIT;
session->local.accepting = 1;
session->remote.accepting = 1;
apr_pool_pre_cleanup_register(pool, session, session_pool_cleanup);
session->max_stream_count = h2_config_geti(session->config,
H2_CONF_MAX_STREAMS);
session->max_stream_mem = h2_config_geti(session->config,
H2_CONF_STREAM_MAX_MEM);
status = apr_thread_cond_create(&session->iowait, session->pool);
if (status != APR_SUCCESS) {
return NULL;
}
session->mplx = h2_mplx_create(c, session->pool, session->config,
session->s->timeout, workers);
h2_mplx_set_consumed_cb(session->mplx, update_window, session);
/* Install the connection input filter that feeds the session */
session->cin = h2_filter_cin_create(session->pool,
h2_session_receive, session);
ap_add_input_filter("H2_IN", session->cin, r, c);
h2_conn_io_init(&session->io, c, session->config);
session->bbtmp = apr_brigade_create(session->pool, c->bucket_alloc);
status = init_callbacks(c, &callbacks);
if (status != APR_SUCCESS) {
ap_log_cerror(APLOG_MARK, APLOG_ERR, status, c, APLOGNO(02927)
"nghttp2: error in init_callbacks");
h2_session_destroy(session);
return NULL;
}
rv = nghttp2_option_new(&options);
if (rv != 0) {
ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, c,
APLOGNO(02928) "nghttp2_option_new: %s",
nghttp2_strerror(rv));
h2_session_destroy(session);
return NULL;
}
nghttp2_option_set_peer_max_concurrent_streams(
options, (uint32_t)session->max_stream_count);
/* We need to handle window updates ourself, otherwise we
* get flooded by nghttp2. */
nghttp2_option_set_no_auto_window_update(options, 1);
if (APLOGctrace6(c)) {
mem = apr_pcalloc(session->pool, sizeof(nghttp2_mem));
mem->mem_user_data = session;
mem->malloc = session_malloc;
mem->free = session_free;
mem->calloc = session_calloc;
mem->realloc = session_realloc;
rv = nghttp2_session_server_new3(&session->ngh2, callbacks,
session, options, mem);
}
else {
rv = nghttp2_session_server_new2(&session->ngh2, callbacks,
session, options);
}
nghttp2_session_callbacks_del(callbacks);
nghttp2_option_del(options);
if (rv != 0) {
ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, c,
APLOGNO(02929) "nghttp2_session_server_new: %s",
nghttp2_strerror(rv));
h2_session_destroy(session);
return NULL;
}
n = h2_config_geti(session->config, H2_CONF_PUSH_DIARY_SIZE);
session->push_diary = h2_push_diary_create(session->pool, n);
if (APLOGcdebug(c)) {
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, c, APLOGNO(03200)
"h2_session(%ld) created, max_streams=%d, "
"stream_mem=%d, workers_limit=%d, workers_max=%d, "
"push_diary(type=%d,N=%d)",
session->id, (int)session->max_stream_count,
(int)session->max_stream_mem,
session->mplx->workers_limit,
session->mplx->workers_max,
session->push_diary->dtype,
(int)session->push_diary->N);
}
}
return session;
}
| 1,581 |
50,095 | 0 | static PRInt32 nspr_io_send(PRFileDesc *fd, const void *buf, PRInt32 amount,
PRIntn flags, PRIntervalTime timeout)
{
const PRSendFN send_fn = fd->lower->methods->send;
const PRInt32 rv = send_fn(fd->lower, buf, amount, flags, timeout);
if(rv < 0)
/* check for PR_WOULD_BLOCK_ERROR and update blocking direction */
nss_update_connecting_state(ssl_connect_2_writing, fd->secret);
return rv;
}
| 1,582 |
10,922 | 0 | parse_response_status (ksba_ocsp_t ocsp,
unsigned char const **data, size_t *datalen,
size_t *rlength)
{
gpg_error_t err;
struct tag_info ti;
char *oid;
*rlength = 0;
/* Parse the OCSPResponse sequence. */
err = parse_sequence (data, datalen, &ti);
if (err)
return err;
/* Parse the OCSPResponseStatus. */
err = parse_enumerated (data, datalen, &ti, 1);
if (err)
return err;
switch (**data)
{
case 0: ocsp->response_status = KSBA_OCSP_RSPSTATUS_SUCCESS; break;
case 1: ocsp->response_status = KSBA_OCSP_RSPSTATUS_MALFORMED; break;
case 2: ocsp->response_status = KSBA_OCSP_RSPSTATUS_INTERNAL; break;
case 3: ocsp->response_status = KSBA_OCSP_RSPSTATUS_TRYLATER; break;
case 5: ocsp->response_status = KSBA_OCSP_RSPSTATUS_SIGREQUIRED; break;
case 6: ocsp->response_status = KSBA_OCSP_RSPSTATUS_UNAUTHORIZED; break;
default: ocsp->response_status = KSBA_OCSP_RSPSTATUS_OTHER; break;
}
parse_skip (data, datalen, &ti);
if (ocsp->response_status)
return 0; /* This is an error reponse; we have to stop here. */
/* We have a successful reponse status, thus we check that
ResponseBytes are actually available. */
err = parse_context_tag (data, datalen, &ti, 0);
if (err)
return err;
err = parse_sequence (data, datalen, &ti);
if (err)
return err;
err = parse_object_id_into_str (data, datalen, &oid);
if (err)
return err;
if (strcmp (oid, oidstr_ocsp_basic))
{
xfree (oid);
return gpg_error (GPG_ERR_UNSUPPORTED_PROTOCOL);
}
xfree (oid);
/* Check that the next field is an octet string. */
err = parse_octet_string (data, datalen, &ti);
if (err)
return err;
*rlength = ti.length;
return 0;
}
| 1,583 |
67,919 | 0 | static void jas_stream_initbuf(jas_stream_t *stream, int bufmode, char *buf,
int bufsize)
{
/* If this function is being called, the buffer should not have been
initialized yet. */
assert(!stream->bufbase_);
if (bufmode != JAS_STREAM_UNBUF) {
/* The full- or line-buffered mode is being employed. */
if (!buf) {
/* The caller has not specified a buffer to employ, so allocate
one. */
if ((stream->bufbase_ = jas_malloc(JAS_STREAM_BUFSIZE +
JAS_STREAM_MAXPUTBACK))) {
stream->bufmode_ |= JAS_STREAM_FREEBUF;
stream->bufsize_ = JAS_STREAM_BUFSIZE;
} else {
/* The buffer allocation has failed. Resort to unbuffered
operation. */
stream->bufbase_ = stream->tinybuf_;
stream->bufsize_ = 1;
}
} else {
/* The caller has specified a buffer to employ. */
/* The buffer must be large enough to accommodate maximum
putback. */
assert(bufsize > JAS_STREAM_MAXPUTBACK);
stream->bufbase_ = JAS_CAST(jas_uchar *, buf);
stream->bufsize_ = bufsize - JAS_STREAM_MAXPUTBACK;
}
} else {
/* The unbuffered mode is being employed. */
/* A buffer should not have been supplied by the caller. */
assert(!buf);
/* Use a trivial one-character buffer. */
stream->bufbase_ = stream->tinybuf_;
stream->bufsize_ = 1;
}
stream->bufstart_ = &stream->bufbase_[JAS_STREAM_MAXPUTBACK];
stream->ptr_ = stream->bufstart_;
stream->cnt_ = 0;
stream->bufmode_ |= bufmode & JAS_STREAM_BUFMODEMASK;
}
| 1,584 |
110,729 | 0 | void AutocompleteInput::Clear() {
text_.clear();
type_ = INVALID;
parts_ = url_parse::Parsed();
scheme_.clear();
desired_tld_.clear();
prevent_inline_autocomplete_ = false;
prefer_keyword_ = false;
}
| 1,585 |
158,486 | 0 | OverscrollMode overscroll_mode() const {
return view_->overscroll_controller()->overscroll_mode_;
}
| 1,586 |
1,800 | 0 | static int name_from_dns_search(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family)
{
char search[256];
struct resolvconf conf;
size_t l, dots;
char *p, *z;
if (__get_resolv_conf(&conf, search, sizeof search) < 0) return -1;
/* Count dots, suppress search when >=ndots or name ends in
* a dot, which is an explicit request for global scope. */
for (dots=l=0; name[l]; l++) if (name[l]=='.') dots++;
if (dots >= conf.ndots || name[l-1]=='.') *search = 0;
/* This can never happen; the caller already checked length. */
if (l >= 256) return EAI_NONAME;
/* Name with search domain appended is setup in canon[]. This both
* provides the desired default canonical name (if the requested
* name is not a CNAME record) and serves as a buffer for passing
* the full requested name to name_from_dns. */
memcpy(canon, name, l);
canon[l] = '.';
for (p=search; *p; p=z) {
for (; isspace(*p); p++);
for (z=p; *z && !isspace(*z); z++);
if (z==p) break;
if (z-p < 256 - l - 1) {
memcpy(canon+l+1, p, z-p);
canon[z-p+1+l] = 0;
int cnt = name_from_dns(buf, canon, canon, family, &conf);
if (cnt) return cnt;
}
}
canon[l] = 0;
return name_from_dns(buf, canon, name, family, &conf);
}
| 1,587 |
17,783 | 0 | DetachOutputGPU(ScreenPtr slave)
{
assert(slave->isGPU);
assert(slave->is_output_slave);
slave->current_master->output_slaves--;
slave->is_output_slave = FALSE;
}
| 1,588 |
40,517 | 0 | static int netlink_broadcast_deliver(struct sock *sk, struct sk_buff *skb)
{
struct netlink_sock *nlk = nlk_sk(sk);
if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf &&
!test_bit(NETLINK_CONGESTED, &nlk->state)) {
netlink_skb_set_owner_r(skb, sk);
__netlink_sendskb(sk, skb);
return atomic_read(&sk->sk_rmem_alloc) > (sk->sk_rcvbuf >> 1);
}
return -1;
}
| 1,589 |
105,532 | 0 | bool SendAcceptPromptAppModalDialogJSONRequest(
AutomationMessageSender* sender,
const std::string& prompt_text,
std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "AcceptOrDismissAppModalDialog");
dict.SetBoolean("accept", true);
dict.SetString("prompt_text", prompt_text);
DictionaryValue reply_dict;
return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
| 1,590 |
171,143 | 0 | void MediaPlayerService::AudioOutput::close_l()
{
mTrack.clear();
}
| 1,591 |
75,724 | 0 | void testCompareRangeHelper(const char * a, const char * b, int expected, bool avoidNullRange = true) {
UriTextRangeA ra;
UriTextRangeA rb;
if (a) {
ra.first = a;
ra.afterLast = a + strlen(a);
} else {
ra.first = NULL;
ra.afterLast = NULL;
}
if (b) {
rb.first = b;
rb.afterLast = b + strlen(b);
} else {
rb.first = NULL;
rb.afterLast = NULL;
}
const int received = uriCompareRangeA(
((a == NULL) && avoidNullRange) ? NULL : &ra,
((b == NULL) && avoidNullRange) ? NULL : &rb);
if (received != expected) {
printf("Comparing <%s> to <%s> yields %d, expected %d.\n",
a, b, received, expected);
}
TEST_ASSERT(received == expected);
}
| 1,592 |
29,127 | 0 | static int buf_to_pages_noslab(const void *buf, size_t buflen,
struct page **pages, unsigned int *pgbase)
{
struct page *newpage, **spages;
int rc = 0;
size_t len;
spages = pages;
do {
len = min_t(size_t, PAGE_SIZE, buflen);
newpage = alloc_page(GFP_KERNEL);
if (newpage == NULL)
goto unwind;
memcpy(page_address(newpage), buf, len);
buf += len;
buflen -= len;
*pages++ = newpage;
rc++;
} while (buflen != 0);
return rc;
unwind:
for(; rc > 0; rc--)
__free_page(spages[rc-1]);
return -ENOMEM;
}
| 1,593 |
126,139 | 0 | BrowserLauncherItemController* BrowserLauncherItemController::Create(
Browser* browser) {
if (!ChromeLauncherController::instance())
return NULL;
Type type;
std::string app_id;
if (browser->is_type_tabbed() || browser->is_type_popup()) {
type = TYPE_TABBED;
} else if (browser->is_app()) {
if (browser->is_type_panel()) {
if (browser->app_type() == Browser::APP_TYPE_CHILD)
type = TYPE_EXTENSION_PANEL;
else
type = TYPE_APP_PANEL;
} else {
type = TYPE_TABBED;
}
app_id = web_app::GetExtensionIdFromApplicationName(browser->app_name());
} else {
return NULL;
}
BrowserLauncherItemController* controller =
new BrowserLauncherItemController(type,
browser->window()->GetNativeWindow(),
browser->tab_strip_model(),
ChromeLauncherController::instance(),
app_id);
controller->Init();
return controller;
}
| 1,594 |
155,553 | 0 | base::string16 AuthenticatorNotRegisteredErrorModel::GetCancelButtonLabel()
const {
return l10n_util::GetStringUTF16(IDS_CLOSE);
}
| 1,595 |
128,325 | 0 | IntSize FrameView::scrollOffsetForFixedPosition() const
{
return toIntSize(clampScrollPosition(scrollPosition()));
}
| 1,596 |
170,699 | 0 | static EAS_RESULT Parse_rgnh (SDLS_SYNTHESIZER_DATA *pDLSData, EAS_I32 pos, S_DLS_REGION *pRgn)
{
EAS_RESULT result;
EAS_U16 lowKey;
EAS_U16 highKey;
EAS_U16 lowVel;
EAS_U16 highVel;
EAS_U16 optionFlags;
EAS_U16 keyGroup;
/* seek to start of chunk */
if ((result = EAS_HWFileSeek(pDLSData->hwInstData, pDLSData->fileHandle, pos)) != EAS_SUCCESS)
return result;
/* get the key range */
if ((result = EAS_HWGetWord(pDLSData->hwInstData, pDLSData->fileHandle, &lowKey, EAS_FALSE)) != EAS_SUCCESS)
return result;
if ((result = EAS_HWGetWord(pDLSData->hwInstData, pDLSData->fileHandle, &highKey, EAS_FALSE)) != EAS_SUCCESS)
return result;
/* check the range */
if (lowKey > 127)
{
{ /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "DLS rgnh: Low key out of range [%u]\n", lowKey); */ }
lowKey = 127;
}
if (highKey > 127)
{
{ /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "DLS rgnh: High key out of range [%u]\n", lowKey); */ }
highKey = 127;
}
/* get the velocity range */
if ((result = EAS_HWGetWord(pDLSData->hwInstData, pDLSData->fileHandle, &lowVel, EAS_FALSE)) != EAS_SUCCESS)
return result;
if ((result = EAS_HWGetWord(pDLSData->hwInstData, pDLSData->fileHandle, &highVel, EAS_FALSE)) != EAS_SUCCESS)
return result;
/* check the range */
if (lowVel > 127)
{
{ /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "DLS rgnh: Low velocity out of range [%u]\n", lowVel); */ }
lowVel = 127;
}
if (highVel > 127)
{
{ /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "DLS rgnh: High velocity out of range [%u]\n", highVel); */ }
highVel = 127;
}
/* get the option flags */
if ((result = EAS_HWGetWord(pDLSData->hwInstData, pDLSData->fileHandle, &optionFlags, EAS_FALSE)) != EAS_SUCCESS)
return result;
/* get the key group */
if ((result = EAS_HWGetWord(pDLSData->hwInstData, pDLSData->fileHandle, &keyGroup, EAS_FALSE)) != EAS_SUCCESS)
return result;
/* save the key range and key group */
pRgn->wtRegion.region.rangeLow = (EAS_U8) lowKey;
pRgn->wtRegion.region.rangeHigh = (EAS_U8) highKey;
/*lint -e{734} keyGroup will always be from 0-15 */
pRgn->wtRegion.region.keyGroupAndFlags = keyGroup << 8;
pRgn->velLow = (EAS_U8) lowVel;
pRgn->velHigh = (EAS_U8) highVel;
if (optionFlags & F_RGN_OPTION_SELFNONEXCLUSIVE)
pRgn->wtRegion.region.keyGroupAndFlags |= REGION_FLAG_NON_SELF_EXCLUSIVE;
return EAS_SUCCESS;
}
| 1,597 |
132,396 | 0 | void FlagsState::RemoveFlagsSwitches(
std::map<std::string, base::CommandLine::StringType>* switch_list) {
for (const auto& entry : flags_switches_)
switch_list->erase(entry.first);
}
| 1,598 |
173,142 | 0 | perform_one_test_safe(FILE *fp, int argc, const char **argv,
png_uint_32 *default_flags, display *d, const char *test)
{
if (setjmp(d->error_return) == 0)
{
d->test = test; /* allow use of d->error_return */
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
perform_one_test(fp, argc, argv, default_flags, d, 0);
# endif
# ifdef PNG_READ_USER_CHUNKS_SUPPORTED
perform_one_test(fp, argc, argv, default_flags, d, 1);
# endif
d->test = init; /* prevent use of d->error_return */
}
}
| 1,599 |
Subsets and Splits