problem
stringlengths
26
131k
labels
class label
2 classes
Take some Random numbers as a input print the numbers in descending order : # include<iostream> using namespace std; int print_max(int a, int b); main() { int low=0,max,min; int num[5]; for(int i=1; i<=5; i++) { cout<<"Plz Enter the number "<<endl; cin>>num[i]; low=print_max(num[i],low); max=print_max(num[i],low); } cout<<max; for(int i=1; i<=5; i++) { if(max>num[i]) min=num[i]; cout<<min; } } int print_max(int a,int b) { int max; if (a>b) {max=a; return max;} else { max=b; return max; } } I wanna convert some random number which i have taken as a input in the descending order "low" will save the greater number and then "max"will compare all the value with low and will save the greater value .then i inserted the condition of "if" in the loop it will compare all the values of input with "max" and find the minimum values but it do not give the fine output.
0debug
Extract float numbers from string in python : <p>i want to extract the numbers from the <strong>following string</strong>:</p> <p>FRESENIUS44.42 BAYER64.90 FRESENIUS MEDICAL CARE59.12 COVESTRO45.34 BASF63.19</p> <p>I've tried the following approach but that didn't work:</p> <pre><code>l = [] for t in xs.split(): try: l.append(float(t)) except ValueError: pass </code></pre> <p>The <strong>result</strong> should be 44.42 64.90 59.12 45.34 63.19</p> <p>Thank you!</p>
0debug
static void process_synthesis_subpackets(QDM2Context *q, QDM2SubPNode *list) { QDM2SubPNode *nodes[4]; nodes[0] = qdm2_search_subpacket_type_in_list(list, 9); if (nodes[0] != NULL) process_subpacket_9(q, nodes[0]); nodes[1] = qdm2_search_subpacket_type_in_list(list, 10); if (nodes[1] != NULL) process_subpacket_10(q, nodes[1]); else process_subpacket_10(q, NULL); nodes[2] = qdm2_search_subpacket_type_in_list(list, 11); if (nodes[0] != NULL && nodes[1] != NULL && nodes[2] != NULL) process_subpacket_11(q, nodes[2]); else process_subpacket_11(q, NULL); nodes[3] = qdm2_search_subpacket_type_in_list(list, 12); if (nodes[0] != NULL && nodes[1] != NULL && nodes[3] != NULL) process_subpacket_12(q, nodes[3]); else process_subpacket_12(q, NULL); }
1threat
static void boston_flash_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { }
1threat
C do{} while(function(argumen)==1) in I/O FILES : <p>So i need to enter ID(int)(it has to be a 3 digit format) argument and make a check function if there is same ID in FILE datoteka.txt that i made. Thanks for help</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; struct struktura{ int ID; char imeprezime[20]; int placa; int godina; }; int clear_input_buffer(void) { int ch; while (((ch = getchar()) != EOF) &amp;&amp; (ch != '\n')) /* void */; return ch; } </code></pre> <p>ID check :cant get it to return flag = 1;</p> <pre><code>//function that should check if there is same ID as the one you enter //returning 1 if there is same ID or 0 if there is not int provjera(int IDprovjera){ int flag=0; int datID; FILE *datprovjera = NULL; datprovjera = fopen("datoteka.txt","r"); if(datprovjera == NULL){ printf("Nema datoteke!"); exit(2); } while(fscanf(datprovjera,"%d#%[^#]#%d#%d#",&amp;datID)==4){ if (datID == IDprovjera){ flag=1; break; } } fclose(datprovjera); return flag; } </code></pre> <p>Main</p> <pre><code>int main() { int i,M; int provjera_2; struct struktura radnik; FILE *datoteka = NULL; datoteka = fopen("datoteka.txt","w"); if (datoteka == NULL){ printf("Greska!"); exit(1); } printf("Unesi broj radnika:\n"); scanf("%d",&amp;M); for(i=0;i&lt;M;i++){ //ID do{ do{ printf("Unesi ID\n"); scanf("%d",&amp;radnik.ID); clear_input_buffer(); }while( provjera(radnik.ID)!=0); }while( radnik.ID/100&gt;9 || radnik.ID/100&lt;1); fprintf(datoteka,"%d",radnik.ID); fprintf(datoteka,"%c",'#'); //Ime Prezime printf("Unesi ime i prezime radnika:\n"); gets(radnik.imeprezime); fprintf(datoteka,"%s",radnik.imeprezime); fprintf(datoteka,"%c",'#'); //Placa printf("Unesi placu radnika:\n"); scanf("%d",&amp;radnik.placa); fprintf(datoteka,"%d",radnik.placa); fprintf(datoteka,"%c",'#'); //Godine do{ printf("Unesi godinu pocetka rada:\n"); scanf("%d",&amp;radnik.godina); clear_input_buffer(); }while( radnik.godina&lt;1970 || radnik.godina&gt;2016); fprintf(datoteka,"%d",radnik.godina); fprintf(datoteka,"%c\n",'#'); } fclose(datoteka); </code></pre>
0debug
int avpriv_dca_parse_core_frame_header(GetBitContext *gb, DCACoreFrameHeader *h) { if (get_bits_long(gb, 32) != DCA_SYNCWORD_CORE_BE) return DCA_PARSE_ERROR_SYNC_WORD; h->normal_frame = get_bits1(gb); h->deficit_samples = get_bits(gb, 5) + 1; if (h->deficit_samples != DCA_PCMBLOCK_SAMPLES) return DCA_PARSE_ERROR_DEFICIT_SAMPLES; h->crc_present = get_bits1(gb); h->npcmblocks = get_bits(gb, 7) + 1; if (h->npcmblocks & (DCA_SUBBAND_SAMPLES - 1)) return DCA_PARSE_ERROR_PCM_BLOCKS; h->frame_size = get_bits(gb, 14) + 1; if (h->frame_size < 96) return DCA_PARSE_ERROR_FRAME_SIZE; h->audio_mode = get_bits(gb, 6); if (h->audio_mode >= DCA_AMODE_COUNT) return DCA_PARSE_ERROR_AMODE; h->sr_code = get_bits(gb, 4); if (!avpriv_dca_sample_rates[h->sr_code]) return DCA_PARSE_ERROR_SAMPLE_RATE; h->br_code = get_bits(gb, 5); if (get_bits1(gb)) return DCA_PARSE_ERROR_RESERVED_BIT; h->drc_present = get_bits1(gb); h->ts_present = get_bits1(gb); h->aux_present = get_bits1(gb); h->hdcd_master = get_bits1(gb); h->ext_audio_type = get_bits(gb, 3); h->ext_audio_present = get_bits1(gb); h->sync_ssf = get_bits1(gb); h->lfe_present = get_bits(gb, 2); if (h->lfe_present == DCA_LFE_FLAG_INVALID) return DCA_PARSE_ERROR_LFE_FLAG; h->predictor_history = get_bits1(gb); if (h->crc_present) skip_bits(gb, 16); h->filter_perfect = get_bits1(gb); h->encoder_rev = get_bits(gb, 4); h->copy_hist = get_bits(gb, 2); h->pcmr_code = get_bits(gb, 3); if (!ff_dca_bits_per_sample[h->pcmr_code]) return DCA_PARSE_ERROR_PCM_RES; h->sumdiff_front = get_bits1(gb); h->sumdiff_surround = get_bits1(gb); h->dn_code = get_bits(gb, 4); return 0; }
1threat
Error using cell2mat Matlab : <p>I have the cell below:</p> <pre><code> aa={[1.0094]} {[1.0370]} {[1.0956]} {[1.0957]} {[1.0171]} {[1.0362]} {[1.1355]} {[1.0503]} {[1.5280]} {[1.1928]} {[1.0148]} {[0.9822]} {[1.0316]} {[1.1135]} {[1.1135]} </code></pre> <p>I used the command cell2mat as below:</p> <pre><code> aa=cell2mat(aa); </code></pre> <p>but it gives me the error below:</p> <pre><code> Error using cell2mat (line 45) All contents of the input cell array must be of the same data type. </code></pre> <p>any idea what to do? Best</p>
0debug
int kvm_arch_put_registers(CPUState *env, int level) { int ret; assert(cpu_is_stopped(env) || qemu_cpu_is_self(env)); ret = kvm_getput_regs(env, 1); ret = kvm_put_xsave(env); ret = kvm_put_xcrs(env); ret = kvm_put_sregs(env); ret = kvm_put_msrs(env, level); if (level >= KVM_PUT_RESET_STATE) { ret = kvm_put_mp_state(env); ret = kvm_put_vcpu_events(env, level); ret = kvm_put_debugregs(env); ret = kvm_guest_debug_workarounds(env); return 0;
1threat
Why templates must be defined outside class : <p>I know that templates must be declared and defined in the same file. But, why I cannot:</p> <pre><code>#ifndef guard #define guard template&lt;typename T&gt; class Test{ void method(){ } }; #endif </code></pre> <p>And it is causes compiler error ( not directly but instatantiation template Test in two different place- for example in main() and as field in any class causes error. </p> <p>It must be defined outside class ( It doesn't cause error like here)</p> <pre><code>#ifndef guard #define guard template&lt;typename T&gt; class Test{ void method(); }; #endif template&lt;typename T&gt; void Test&lt;T&gt;::method(){} </code></pre> <p>Why?</p>
0debug
how can i count the number of times a certain string occurs in a variable? : <p>im just learning how to program on edx, and theres this question that i just can seem to understand not to even talk of solving. please i need solutions and idea on how to understand the question and implement it</p> <ul> <li>QUESTION-</li> </ul> <p>Assume s is a string of lower case characters.</p> <p>Write a program that prints the number of times the string 'bob' occurs in s. For example, if s = 'azcbobobegghakl', then your program should print</p> <p>Number of times bob occurs is: 2</p>
0debug
static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc) { int bits_per_sample, flags; uint16_t version = avio_rb16(pb); AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, "compatible_brands", NULL, AV_DICT_MATCH_CASE); avio_rb16(pb); avio_rb32(pb); st->codec->channels = avio_rb16(pb); st->codec->bits_per_coded_sample = avio_rb16(pb); av_log(c->fc, AV_LOG_TRACE, "audio channels %d\n", st->codec->channels); sc->audio_cid = avio_rb16(pb); avio_rb16(pb); st->codec->sample_rate = ((avio_rb32(pb) >> 16)); av_log(c->fc, AV_LOG_TRACE, "version =%d, isom =%d\n", version, c->isom); if (!c->isom || (compatible_brands && strstr(compatible_brands->value, "qt "))) { if (version == 1) { sc->samples_per_frame = avio_rb32(pb); avio_rb32(pb); sc->bytes_per_frame = avio_rb32(pb); avio_rb32(pb); } else if (version == 2) { avio_rb32(pb); st->codec->sample_rate = av_int2double(avio_rb64(pb)); st->codec->channels = avio_rb32(pb); avio_rb32(pb); st->codec->bits_per_coded_sample = avio_rb32(pb); flags = avio_rb32(pb); sc->bytes_per_frame = avio_rb32(pb); sc->samples_per_frame = avio_rb32(pb); if (st->codec->codec_tag == MKTAG('l','p','c','m')) st->codec->codec_id = ff_mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, flags); } if (version == 0 || (version == 1 && sc->audio_cid != -2)) { switch (st->codec->codec_id) { case AV_CODEC_ID_MP2: case AV_CODEC_ID_MP3: st->need_parsing = AVSTREAM_PARSE_FULL; break; } } } if (sc->format == 0) { if (st->codec->bits_per_coded_sample == 8) st->codec->codec_id = mov_codec_id(st, MKTAG('r','a','w',' ')); else if (st->codec->bits_per_coded_sample == 16) st->codec->codec_id = mov_codec_id(st, MKTAG('t','w','o','s')); } switch (st->codec->codec_id) { case AV_CODEC_ID_PCM_S8: case AV_CODEC_ID_PCM_U8: if (st->codec->bits_per_coded_sample == 16) st->codec->codec_id = AV_CODEC_ID_PCM_S16BE; break; case AV_CODEC_ID_PCM_S16LE: case AV_CODEC_ID_PCM_S16BE: if (st->codec->bits_per_coded_sample == 8) st->codec->codec_id = AV_CODEC_ID_PCM_S8; else if (st->codec->bits_per_coded_sample == 24) st->codec->codec_id = st->codec->codec_id == AV_CODEC_ID_PCM_S16BE ? AV_CODEC_ID_PCM_S24BE : AV_CODEC_ID_PCM_S24LE; else if (st->codec->bits_per_coded_sample == 32) st->codec->codec_id = st->codec->codec_id == AV_CODEC_ID_PCM_S16BE ? AV_CODEC_ID_PCM_S32BE : AV_CODEC_ID_PCM_S32LE; break; case AV_CODEC_ID_MACE3: sc->samples_per_frame = 6; sc->bytes_per_frame = 2 * st->codec->channels; break; case AV_CODEC_ID_MACE6: sc->samples_per_frame = 6; sc->bytes_per_frame = 1 * st->codec->channels; break; case AV_CODEC_ID_ADPCM_IMA_QT: sc->samples_per_frame = 64; sc->bytes_per_frame = 34 * st->codec->channels; break; case AV_CODEC_ID_GSM: sc->samples_per_frame = 160; sc->bytes_per_frame = 33; break; default: break; } bits_per_sample = av_get_bits_per_sample(st->codec->codec_id); if (bits_per_sample) { st->codec->bits_per_coded_sample = bits_per_sample; sc->sample_size = (bits_per_sample >> 3) * st->codec->channels; } }
1threat
Which is more preferable? Performance or Memory while spliting a string in C#? : <p>I would like to ask that which case of the two below is more preferable than the other considering garbage collection, memory and cpu usage in C#.</p> <pre><code>a = data.Split('|')[0]; b = data.Split('|')[1]; c = data.Split('|')[2]; d = data.Split('|')[3]; e = data.Split('|')[4]; </code></pre> <p>or</p> <pre><code>string[] splitedData = data.Split('|'); a= splitedData[0]; b = splitedData[1]; c = splitedData[2]; d = splitedData[3]; e = splitedData[4]; </code></pre> <p>I would prefer the second one since I think holding the splited data array reference and accessing from using that reference is less cpu-intensive and uses less memory access.</p> <p>The first one uses more cpu and creates an array at each time (filling and accessing the array requires also more memory operation) in order to get the data accordingly.</p> <p>I am asking this question because I saw in a game project created by Chupamobile that the first one was used.</p> <p>Thanks in advance.</p>
0debug
Office 365 - Distribution groups On premises to Cloud : <p>I am performing the migration in a hybrid environment: Office365 / Exchange. Our users are synchronized using AD Connect and the email boxes have already been migrated from on premises to the cloud. The intention is to later disable the exchange on premises server.</p> <p>My question is regarding distribution groups. If I uninstall the exchange server, does migration of the distribution groups to the cloud necessary? Because these groups are created in Active Directory and synchronized with my tenant. If I uninstall Exchange, will those groups be removed too?</p>
0debug
How can I access an instance outside of the method it was created in? C# : I am working on a console app that transmits OutGauge data to an Adruino, but I'm stuck with the problem described below. Here's the top of my code: using System; using InSimDotNet.Out; using ArduinoDriver; using ArduinoUploader.Hardware; using ArduinoDriver.SerialProtocol; class Program { static void Main() { var driver = new ArduinoDriver.ArduinoDriver(ArduinoModel.NanoR3, true); I need to access "driver"(,which I created in the Main method) in outgauge_PacketReceived(). To be specific, I need to use it's Send() method. static void outgauge_PacketReceived(object sender, OutGaugeEventArgs e) { //I need driver.Send() here. }
0debug
POP an integer out of a list and keep going til list is gone? : I have created a random list and trying to pop a number out by using a userInput and keep going but it keeps giving me the error, pop index out of range. Even .remove() is not working. I am a little confused. import random hand= [] for i in range(10): hand.append(random.randrange(1,10)) print (hand) userInput = int(input("What card do you want to play? ")) while True: if userInput > 0: hand.pop(userInput)
0debug
static uint64_t kvmppc_read_int_cpu_dt(const char *propname) { char buf[PATH_MAX]; union { uint32_t v32; uint64_t v64; } u; FILE *f; int len; if (kvmppc_find_cpu_dt(buf, sizeof(buf))) { return -1; } strncat(buf, "/", sizeof(buf) - strlen(buf)); strncat(buf, propname, sizeof(buf) - strlen(buf)); f = fopen(buf, "rb"); if (!f) { return -1; } len = fread(&u, 1, sizeof(u), f); fclose(f); switch (len) { case 4: return be32_to_cpu(u.v32); case 8: return be64_to_cpu(u.v64); } return 0; }
1threat
C++ For loops: N lines of input : I am only just learning C++ so I am not sure how to do this. The question asks me to determine whether LHS of an simple expression equals its RHS. The input consists of an integer N, and then N lines of expressions. The output also consists of N lines, whether the expression is correct or not (output "CORRECT" or "WRONG", excluding quotations). So I attempted to write a for loop for N lines of input, for (int i=1; i<=n; ++i), but I have no idea what else to include inside the for loop. Also how do you verify whether the equation's LHS equals its RHS? Idk about that too.
0debug
AVCodecParserContext *av_parser_init(int codec_id) { AVCodecParserContext *s; AVCodecParser *parser; int ret; if(codec_id == CODEC_ID_NONE) return NULL; for(parser = av_first_parser; parser != NULL; parser = parser->next) { if (parser->codec_ids[0] == codec_id || parser->codec_ids[1] == codec_id || parser->codec_ids[2] == codec_id || parser->codec_ids[3] == codec_id || parser->codec_ids[4] == codec_id) goto found; } return NULL; found: s = av_mallocz(sizeof(AVCodecParserContext)); if (!s) return NULL; s->parser = parser; if (parser->priv_data_size) { s->priv_data = av_mallocz(parser->priv_data_size); if (!s->priv_data) { av_free(s); return NULL; } } if (parser->parser_init) { ret = parser->parser_init(s); if (ret != 0) { av_free(s->priv_data); av_free(s); return NULL; } } s->fetch_timestamp=1; s->pict_type = FF_I_TYPE; s->key_frame = -1; s->convergence_duration = 0; s->dts_sync_point = INT_MIN; s->dts_ref_dts_delta = INT_MIN; s->pts_dts_delta = INT_MIN; return s; }
1threat
static inline hwaddr booke206_page_size_to_tlb(uint64_t size) { return (ffs(size >> 10) - 1) >> 1; }
1threat
Python defaultdict initialise while creation : <p>Is there any way of initialise defaultdict during creation time ? I mean to achieve the same behaviour as this in one line:</p> <pre><code>x = defaultdict(int) x[1] = 2 </code></pre> <p>something like:</p> <pre><code>x = defaultdict(int, {1:2}) </code></pre> <p>where <code>x[1] = 2</code> and rest all values are 0.</p>
0debug
How can i get location on center of screen with Google Map Api : <p>I need to make it like in PlacePicker API But i want it to mapsActivity when move screen location is change on center of screen plz guide me</p>
0debug
def rombus_area(p,q): area=(p*q)/2 return area
0debug
How to convert Int to Hex String in Kotlin? : <p>I'm looking for a similar function to Java's <code>Integer.toHexString()</code> in Kotlin. Is there something built-in, or we have to manually write a function to convert <code>Int</code> to <code>String</code>?</p>
0debug
int socket_dgram(SocketAddressLegacy *remote, SocketAddressLegacy *local, Error **errp) { int fd; switch (remote->type) { case SOCKET_ADDRESS_LEGACY_KIND_INET: fd = inet_dgram_saddr(remote->u.inet.data, local ? local->u.inet.data : NULL, errp); break; default: error_setg(errp, "socket type unsupported for datagram"); fd = -1; } return fd; }
1threat
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
Idiomatic way to append an element in JSX : <p>Given the following JSX:</p> <pre><code>const elems = &lt;div&gt;&lt;p&gt;hello&lt;/p&gt;&lt;p&gt;world&lt;/p&gt;&lt;/div&gt; </code></pre> <p>If I want to add another element to the end, is there a more idiomatic way than doing:</p> <pre><code>const moreElems = &lt;div&gt;{elems}&lt;p&gt;additional&lt;/p&gt;&lt;/div&gt; </code></pre> <p>Maybe something like:</p> <pre><code>elems.push(&lt;p&gt;additional&lt;/p&gt;) </code></pre> <p>I would be fine omitting the wrapper <code>div</code>; that's just so there's only a single top-level JSX element.</p>
0debug
static int virtqueue_num_heads(VirtQueue *vq, unsigned int idx) { uint16_t num_heads = vring_avail_idx(vq) - idx; if (num_heads > vq->vring.num) { error_report("Guest moved used index from %u to %u", idx, vring_avail_idx(vq)); exit(1); } if (num_heads) { smp_rmb(); } return num_heads; }
1threat
How to make a particular Text Bold after a Text : <p>Suppose I have a sample text. var sample="id:123 Hello How are you id:456 I am fine".</p> <p>123 and 456 are ids. There can be multiple ids in a sentence. So, How to make every id bold in the sentence. And then after that how to remove "id:" from the sample text.</p>
0debug
What is the output of this C program? : I expect the output to be "short int" but the output is "float". #include <stdio.h> int main() { int x = 1; short int i = 2; float f = 3; if (sizeof((x == 2) ? f : i) == sizeof(float)) printf("float\n"); else if (sizeof((x == 2) ? f : i) == sizeof(short int)) printf("short int\n"); }
0debug
How to solve "Error: Uncaught (in promise): Error: No provider for" error in Ionic 3 : <p>I'm learning Ionic 3 and I'm getting this error when trying to make a custom validator which checks for a unique username. I've tried my best but couldn't solve this issue.</p> <p>CustomValidators.ts</p> <pre><code>import { Directive, Input } from '@angular/core'; import { FormControl, Validator, AbstractControl } from '@angular/forms'; import { Http, Response, Headers, RequestOptions } from '@angular/http'; import {Observable} from 'rxjs/Rx'; export class CustomValidators { constructor(public http: Http){} public hasUniqueEmail( control: FormControl, ){ return this.http.get('assets/users.json') .map(res =&gt; res.json()) .catch((error:any) =&gt; Observable.throw(error.json().error || 'Server error')); } } </code></pre> <p>signup.ts</p> <pre><code>import { Component } from '@angular/core'; import { IonicPage, NavController, NavParams } from 'ionic-angular'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { CustomValidators } from '../../components/CustomValidators'; /** * Generated class for the SignupPage page. * * See http://ionicframework.com/docs/components/#navigation for more info * on Ionic pages and navigation. */ @IonicPage() @Component({ selector: 'page-signup', templateUrl: 'signup.html', }) export class SignupPage { private sform : FormGroup; constructor( private formBuilder: FormBuilder, private myValidator: CustomValidators, ){ this.sform = this.formBuilder.group({ name: ['', Validators.compose([Validators.maxLength(30), Validators.pattern('[a-zA-Z ]*'), Validators.required])], email: ['', Validators.compose([Validators.email,this.myValidator.hasUniqueEmail])], password: ['',Validators.required ], }); } logForm() { } } </code></pre> <p>This is the error that I'm getting:</p> <pre><code>"Uncaught (in promise): Error: No provider for CustomValidators! Error at Error (native) at injectionError (http://localhost:8100/build/main.js:1583:86) at noProviderError (http://localhost:8100/build/main.js:1621:12) at ReflectiveInjector_._throwOrNull (http://localhost:8100/build/main.js:3122:19) at ReflectiveInjector_._getByKeyDefault (http://localhost:8100/build/main.js:3161:25) at ReflectiveInjector_._getByKey (http://localhost:8100/build/main.js:3093:25) at ReflectiveInjector_.get (http://localhost:8100/build/main.js:2962:21) at NgModuleInjector.get (http://localhost:8100/build/main.js:3909:52) at resolveDep (http://localhost:8100/build/main.js:11369:45) at createClass (http://localhost:8100/build/main.js:11225:91)" </code></pre>
0debug
static inline int get_amv(Mpeg4DecContext *ctx, int n) { MpegEncContext *s = &ctx->m; int x, y, mb_v, sum, dx, dy, shift; int len = 1 << (s->f_code + 4); const int a = s->sprite_warping_accuracy; if (s->workaround_bugs & FF_BUG_AMV) len >>= s->quarter_sample; if (s->real_sprite_warping_points == 1) { if (ctx->divx_version == 500 && ctx->divx_build == 413) sum = s->sprite_offset[0][n] / (1 << (a - s->quarter_sample)); else sum = RSHIFT(s->sprite_offset[0][n] << s->quarter_sample, a); } else { dx = s->sprite_delta[n][0]; dy = s->sprite_delta[n][1]; shift = ctx->sprite_shift[0]; if (n) dy -= 1 << (shift + a + 1); else dx -= 1 << (shift + a + 1); mb_v = s->sprite_offset[0][n] + dx * s->mb_x * 16 + dy * s->mb_y * 16; sum = 0; for (y = 0; y < 16; y++) { int v; v = mb_v + dy * y; for (x = 0; x < 16; x++) { sum += v >> shift; v += dx; } } sum = RSHIFT(sum, a + 8 - s->quarter_sample); } if (sum < -len) sum = -len; else if (sum >= len) sum = len - 1; return sum; }
1threat
static void __attribute__((__constructor__)) rcu_init(void) { QemuThread thread; qemu_mutex_init(&rcu_gp_lock); qemu_event_init(&rcu_gp_event, true); qemu_event_init(&rcu_call_ready_event, false); qemu_thread_create(&thread, "call_rcu", call_rcu_thread, NULL, QEMU_THREAD_DETACHED); rcu_register_thread(); }
1threat
static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt) { struct video_data *s = ctx->priv_data; struct v4l2_buffer buf = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, .memory = V4L2_MEMORY_MMAP }; int res; pkt->size = 0; while ((res = v4l2_ioctl(s->fd, VIDIOC_DQBUF, &buf)) < 0 && (errno == EINTR)); if (res < 0) { if (errno == EAGAIN) return AVERROR(EAGAIN); res = AVERROR(errno); av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_DQBUF): %s\n", av_err2str(res)); return res; } if (buf.index >= s->buffers) { av_log(ctx, AV_LOG_ERROR, "Invalid buffer index received.\n"); return AVERROR(EINVAL); } atomic_fetch_add(&s->buffers_queued, -1); av_assert0(atomic_load(&s->buffers_queued) >= 1); #ifdef V4L2_BUF_FLAG_ERROR if (buf.flags & V4L2_BUF_FLAG_ERROR) { av_log(ctx, AV_LOG_WARNING, "Dequeued v4l2 buffer contains corrupted data (%d bytes).\n", buf.bytesused); buf.bytesused = 0; } else #endif { if (ctx->video_codec_id == AV_CODEC_ID_CPIA) s->frame_size = buf.bytesused; if (s->frame_size > 0 && buf.bytesused != s->frame_size) { av_log(ctx, AV_LOG_ERROR, "Dequeued v4l2 buffer contains %d bytes, but %d were expected. Flags: 0x%08X.\n", buf.bytesused, s->frame_size, buf.flags); enqueue_buffer(s, &buf); return AVERROR_INVALIDDATA; } } if (atomic_load(&s->buffers_queued) == FFMAX(s->buffers / 8, 1)) { res = av_new_packet(pkt, buf.bytesused); if (res < 0) { av_log(ctx, AV_LOG_ERROR, "Error allocating a packet.\n"); enqueue_buffer(s, &buf); return res; } memcpy(pkt->data, s->buf_start[buf.index], buf.bytesused); res = enqueue_buffer(s, &buf); if (res) { av_packet_unref(pkt); return res; } } else { struct buff_data *buf_descriptor; pkt->data = s->buf_start[buf.index]; pkt->size = buf.bytesused; buf_descriptor = av_malloc(sizeof(struct buff_data)); if (!buf_descriptor) { av_log(ctx, AV_LOG_ERROR, "Failed to allocate a buffer descriptor\n"); enqueue_buffer(s, &buf); return AVERROR(ENOMEM); } buf_descriptor->index = buf.index; buf_descriptor->s = s; pkt->buf = av_buffer_create(pkt->data, pkt->size, mmap_release_buffer, buf_descriptor, 0); if (!pkt->buf) { av_log(ctx, AV_LOG_ERROR, "Failed to create a buffer\n"); enqueue_buffer(s, &buf); av_freep(&buf_descriptor); return AVERROR(ENOMEM); } } pkt->pts = buf.timestamp.tv_sec * INT64_C(1000000) + buf.timestamp.tv_usec; convert_timestamp(ctx, &pkt->pts); return pkt->size; }
1threat
Modifying contents of Android .aar file / Converting to and from .zip format : <p>So I have a .aar file which has a file I need to remove from inside it. </p> <p>I am running on mac and changed the extention from .aar to .zip and unzipped the zip file. I then removed the file from the folder, recompressed it back into a .zip and then tried changing the extension from .zip back to .aar. </p> <p>The problem is that the now modified .aar is not recognized as a .aar file. It is still being registered as a .zip and I can no longer use it in my project. </p> <p>So my question is two fold: </p> <p>1) How can one easily modify the contents of a .aar file and 2) How do you properly convert to/from .aar and .zip? </p>
0debug
void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name) { memory_region_transaction_begin(); as->root = root; as->current_map = g_new(FlatView, 1); flatview_init(as->current_map); as->ioeventfd_nb = 0; as->ioeventfds = NULL; QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link); as->name = g_strdup(name ? name : "anonymous"); address_space_init_dispatch(as); memory_region_update_pending |= root->enabled; memory_region_transaction_commit(); }
1threat
static void virtio_blk_reset(VirtIODevice *vdev) { VirtIOBlock *s = VIRTIO_BLK(vdev); AioContext *ctx; VirtIOBlockReq *req; ctx = blk_get_aio_context(s->blk); aio_context_acquire(ctx); blk_drain(s->blk); while (s->rq) { req = s->rq; s->rq = req->next; virtqueue_detach_element(req->vq, &req->elem, 0); virtio_blk_free_request(req); } if (s->dataplane) { virtio_blk_data_plane_stop(s->dataplane); } aio_context_release(ctx); blk_set_enable_write_cache(s->blk, s->original_wce); }
1threat
static void palmte_init(MachineState *machine) { const char *cpu_model = machine->cpu_model; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; MemoryRegion *address_space_mem = get_system_memory(); struct omap_mpu_state_s *mpu; int flash_size = 0x00800000; int sdram_size = palmte_binfo.ram_size; static uint32_t cs0val = 0xffffffff; static uint32_t cs1val = 0x0000e1a0; static uint32_t cs2val = 0x0000e1a0; static uint32_t cs3val = 0xe1a0e1a0; int rom_size, rom_loaded = 0; MemoryRegion *flash = g_new(MemoryRegion, 1); MemoryRegion *cs = g_new(MemoryRegion, 4); mpu = omap310_mpu_init(address_space_mem, sdram_size, cpu_model); memory_region_init_ram(flash, NULL, "palmte.flash", flash_size, &error_abort); vmstate_register_ram_global(flash); memory_region_set_readonly(flash, true); memory_region_add_subregion(address_space_mem, OMAP_CS0_BASE, flash); memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val, "palmte-cs0", OMAP_CS0_SIZE - flash_size); memory_region_add_subregion(address_space_mem, OMAP_CS0_BASE + flash_size, &cs[0]); memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val, "palmte-cs1", OMAP_CS1_SIZE); memory_region_add_subregion(address_space_mem, OMAP_CS1_BASE, &cs[1]); memory_region_init_io(&cs[2], NULL, &static_ops, &cs2val, "palmte-cs2", OMAP_CS2_SIZE); memory_region_add_subregion(address_space_mem, OMAP_CS2_BASE, &cs[2]); memory_region_init_io(&cs[3], NULL, &static_ops, &cs3val, "palmte-cs3", OMAP_CS3_SIZE); memory_region_add_subregion(address_space_mem, OMAP_CS3_BASE, &cs[3]); palmte_microwire_setup(mpu); qemu_add_kbd_event_handler(palmte_button_event, mpu); palmte_gpio_setup(mpu); if (nb_option_roms) { rom_size = get_image_size(option_rom[0].name); if (rom_size > flash_size) { fprintf(stderr, "%s: ROM image too big (%x > %x)\n", __FUNCTION__, rom_size, flash_size); rom_size = 0; } if (rom_size > 0) { rom_size = load_image_targphys(option_rom[0].name, OMAP_CS0_BASE, flash_size); rom_loaded = 1; } if (rom_size < 0) { fprintf(stderr, "%s: error loading '%s'\n", __FUNCTION__, option_rom[0].name); } } if (!rom_loaded && !kernel_filename && !qtest_enabled()) { fprintf(stderr, "Kernel or ROM image must be specified\n"); exit(1); } palmte_binfo.kernel_filename = kernel_filename; palmte_binfo.kernel_cmdline = kernel_cmdline; palmte_binfo.initrd_filename = initrd_filename; arm_load_kernel(mpu->cpu, &palmte_binfo); }
1threat
ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" after androidx migration : <p>I'm trying to move to migrate to androidx. I used the migration tool in Android Studio. When I do this I get the following stacktrace when I run my app.</p> <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main Process: com.peerke.outdoorpuzzlegame.debug, PID: 10901 java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.peerke.outdoorpuzzlegame.debug-IBtFsngoLqc-cQb_hOO5wQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.peerke.outdoorpuzzlegame.debug-IBtFsngoLqc-cQb_hOO5wQ==/lib/x86, /system/lib]] at android.app.ActivityThread.installProvider(ActivityThread.java:6376) at android.app.ActivityThread.installContentProviders(ActivityThread.java:5932) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5847) at android.app.ActivityThread.access$1000(ActivityThread.java:198) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6649) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826) Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.peerke.outdoorpuzzlegame.debug-IBtFsngoLqc-cQb_hOO5wQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.peerke.outdoorpuzzlegame.debug-IBtFsngoLqc-cQb_hOO5wQ==/lib/x86, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:121) at androidx.core.app.CoreComponentFactory.instantiateProvider(CoreComponentFactory.java:62) at android.app.ActivityThread.installProvider(ActivityThread.java:6360) at android.app.ActivityThread.installContentProviders(ActivityThread.java:5932)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5847)  at android.app.ActivityThread.access$1000(ActivityThread.java:198)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6649)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826)  </code></pre> <p>The exception is correct. android.support.v4.content.FileProvider doesn't exist in my app. But androidx.core.content.FileProvider is included in my app. The big question is why does it want to load the old version of FileProvider? </p>
0debug
static int swScale(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]) { const int srcW= c->srcW; const int dstW= c->dstW; const int dstH= c->dstH; const int chrDstW= c->chrDstW; const int chrSrcW= c->chrSrcW; const int lumXInc= c->lumXInc; const int chrXInc= c->chrXInc; const enum PixelFormat dstFormat= c->dstFormat; const int flags= c->flags; int16_t *vLumFilterPos= c->vLumFilterPos; int16_t *vChrFilterPos= c->vChrFilterPos; int16_t *hLumFilterPos= c->hLumFilterPos; int16_t *hChrFilterPos= c->hChrFilterPos; int16_t *vLumFilter= c->vLumFilter; int16_t *vChrFilter= c->vChrFilter; int16_t *hLumFilter= c->hLumFilter; int16_t *hChrFilter= c->hChrFilter; int32_t *lumMmxFilter= c->lumMmxFilter; int32_t *chrMmxFilter= c->chrMmxFilter; const int vLumFilterSize= c->vLumFilterSize; const int vChrFilterSize= c->vChrFilterSize; const int hLumFilterSize= c->hLumFilterSize; const int hChrFilterSize= c->hChrFilterSize; int16_t **lumPixBuf= c->lumPixBuf; int16_t **chrUPixBuf= c->chrUPixBuf; int16_t **chrVPixBuf= c->chrVPixBuf; int16_t **alpPixBuf= c->alpPixBuf; const int vLumBufSize= c->vLumBufSize; const int vChrBufSize= c->vChrBufSize; uint8_t *formatConvBuffer= c->formatConvBuffer; const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample; const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample); int lastDstY; uint32_t *pal=c->pal_yuv; yuv2planar1_fn yuv2plane1 = c->yuv2plane1; yuv2planarX_fn yuv2planeX = c->yuv2planeX; yuv2interleavedX_fn yuv2nv12cX = c->yuv2nv12cX; yuv2packed1_fn yuv2packed1 = c->yuv2packed1; yuv2packed2_fn yuv2packed2 = c->yuv2packed2; yuv2packedX_fn yuv2packedX = c->yuv2packedX; int should_dither = is9_OR_10BPS(c->srcFormat) || is16BPS(c->srcFormat); int dstY= c->dstY; int lumBufIndex= c->lumBufIndex; int chrBufIndex= c->chrBufIndex; int lastInLumBuf= c->lastInLumBuf; int lastInChrBuf= c->lastInChrBuf; if (isPacked(c->srcFormat)) { src[0]= src[1]= src[2]= src[3]= src[0]; srcStride[0]= srcStride[1]= srcStride[2]= srcStride[3]= srcStride[0]; } srcStride[1]<<= c->vChrDrop; srcStride[2]<<= c->vChrDrop; DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n", src[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3], dst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]); DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n", srcSliceY, srcSliceH, dstY, dstH); DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n", vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize); if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) { static int warnedAlready=0; if (flags & SWS_PRINT_INFO && !warnedAlready) { av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n" " ->cannot do aligned memory accesses anymore\n"); warnedAlready=1; } } if (srcSliceY ==0) { lumBufIndex=-1; chrBufIndex=-1; dstY=0; lastInLumBuf= -1; lastInChrBuf= -1; } if (!should_dither) { c->chrDither8 = c->lumDither8 = ff_sws_pb_64; } lastDstY= dstY; for (;dstY < dstH; dstY++) { const int chrDstY= dstY>>c->chrDstVSubSample; uint8_t *dest[4] = { dst[0] + dstStride[0] * dstY, dst[1] + dstStride[1] * chrDstY, dst[2] + dstStride[2] * chrDstY, (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3] + dstStride[3] * dstY : NULL, }; const int firstLumSrcY= FFMAX(1 - vLumFilterSize, vLumFilterPos[dstY]); const int firstLumSrcY2= FFMAX(1 - vLumFilterSize, vLumFilterPos[FFMIN(dstY | ((1<<c->chrDstVSubSample) - 1), dstH-1)]); const int firstChrSrcY= FFMAX(1 - vChrFilterSize, vChrFilterPos[chrDstY]); int lastLumSrcY = FFMIN(c->srcH, firstLumSrcY + vLumFilterSize) - 1; int lastLumSrcY2 = FFMIN(c->srcH, firstLumSrcY2 + vLumFilterSize) - 1; int lastChrSrcY = FFMIN(c->chrSrcH, firstChrSrcY + vChrFilterSize) - 1; int enough_lines; if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1; if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1; assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1); assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1); DEBUG_BUFFERS("dstY: %d\n", dstY); DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n", firstLumSrcY, lastLumSrcY, lastInLumBuf); DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n", firstChrSrcY, lastChrSrcY, lastInChrBuf); enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample); if (!enough_lines) { lastLumSrcY = srcSliceY + srcSliceH - 1; lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1; DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n", lastLumSrcY, lastChrSrcY); } while(lastInLumBuf < lastLumSrcY) { const uint8_t *src1[4] = { src[0] + (lastInLumBuf + 1 - srcSliceY) * srcStride[0], src[1] + (lastInLumBuf + 1 - srcSliceY) * srcStride[1], src[2] + (lastInLumBuf + 1 - srcSliceY) * srcStride[2], src[3] + (lastInLumBuf + 1 - srcSliceY) * srcStride[3], }; lumBufIndex++; assert(lumBufIndex < 2*vLumBufSize); assert(lastInLumBuf + 1 - srcSliceY < srcSliceH); assert(lastInLumBuf + 1 - srcSliceY >= 0); hyscale(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize, formatConvBuffer, pal, 0); if (CONFIG_SWSCALE_ALPHA && alpPixBuf) hyscale(c, alpPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize, formatConvBuffer, pal, 1); lastInLumBuf++; DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n", lumBufIndex, lastInLumBuf); } while(lastInChrBuf < lastChrSrcY) { const uint8_t *src1[4] = { src[0] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[0], src[1] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[1], src[2] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[2], src[3] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[3], }; chrBufIndex++; assert(chrBufIndex < 2*vChrBufSize); assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH)); assert(lastInChrBuf + 1 - chrSrcSliceY >= 0); if (c->needs_hcscale) hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex], chrDstW, src1, chrSrcW, chrXInc, hChrFilter, hChrFilterPos, hChrFilterSize, formatConvBuffer, pal); lastInChrBuf++; DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n", chrBufIndex, lastInChrBuf); } if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize; if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize; if (!enough_lines) break; #if HAVE_MMX updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf); #endif if (should_dither) { c->chrDither8 = dither_8x8_128[chrDstY & 7]; c->lumDither8 = dither_8x8_128[dstY & 7]; } if (dstY >= dstH-2) { ff_sws_init_output_funcs(c, &yuv2plane1, &yuv2planeX, &yuv2nv12cX, &yuv2packed1, &yuv2packed2, &yuv2packedX); } { const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) { const int16_t **tmpY = (const int16_t **) lumPixBuf + 2 * vLumBufSize; int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize); for (i = 0; i < neg; i++) tmpY[i] = lumSrcPtr[neg]; for ( ; i < end; i++) tmpY[i] = lumSrcPtr[i]; for ( ; i < vLumFilterSize; i++) tmpY[i] = tmpY[i-1]; lumSrcPtr = tmpY; if (alpSrcPtr) { const int16_t **tmpA = (const int16_t **) alpPixBuf + 2 * vLumBufSize; for (i = 0; i < neg; i++) tmpA[i] = alpSrcPtr[neg]; for ( ; i < end; i++) tmpA[i] = alpSrcPtr[i]; for ( ; i < vLumFilterSize; i++) tmpA[i] = tmpA[i - 1]; alpSrcPtr = tmpA; } } if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) { const int16_t **tmpU = (const int16_t **) chrUPixBuf + 2 * vChrBufSize, **tmpV = (const int16_t **) chrVPixBuf + 2 * vChrBufSize; int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize); for (i = 0; i < neg; i++) { tmpU[i] = chrUSrcPtr[neg]; tmpV[i] = chrVSrcPtr[neg]; } for ( ; i < end; i++) { tmpU[i] = chrUSrcPtr[i]; tmpV[i] = chrVSrcPtr[i]; } for ( ; i < vChrFilterSize; i++) { tmpU[i] = tmpU[i - 1]; tmpV[i] = tmpV[i - 1]; } chrUSrcPtr = tmpU; chrVSrcPtr = tmpV; } if (isPlanarYUV(dstFormat) || (isGray(dstFormat) && !isALPHA(dstFormat))) { const int chrSkipMask= (1<<c->chrDstVSubSample)-1; if (vLumFilterSize == 1) { yuv2plane1(lumSrcPtr[0], dest[0], dstW, c->lumDither8, 0); } else { yuv2planeX(vLumFilter + dstY * vLumFilterSize, vLumFilterSize, lumSrcPtr, dest[0], dstW, c->lumDither8, 0); } if (!((dstY&chrSkipMask) || isGray(dstFormat))) { if (yuv2nv12cX) { yuv2nv12cX(c, vChrFilter + chrDstY * vChrFilterSize, vChrFilterSize, chrUSrcPtr, chrVSrcPtr, dest[1], chrDstW); } else if (vChrFilterSize == 1) { yuv2plane1(chrUSrcPtr[0], dest[1], chrDstW, c->chrDither8, 0); yuv2plane1(chrVSrcPtr[0], dest[2], chrDstW, c->chrDither8, 3); } else { yuv2planeX(vChrFilter + chrDstY * vChrFilterSize, vChrFilterSize, chrUSrcPtr, dest[1], chrDstW, c->chrDither8, 0); yuv2planeX(vChrFilter + chrDstY * vChrFilterSize, vChrFilterSize, chrVSrcPtr, dest[2], chrDstW, c->chrDither8, 3); } } if (CONFIG_SWSCALE_ALPHA && alpPixBuf){ if (vLumFilterSize == 1) { yuv2plane1(alpSrcPtr[0], dest[3], dstW, c->lumDither8, 0); } else { yuv2planeX(vLumFilter + dstY * vLumFilterSize, vLumFilterSize, alpSrcPtr, dest[3], dstW, c->lumDither8, 0); } } } else { assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2); if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize <= 2) { int chrAlpha = vChrFilterSize == 1 ? 0 : vChrFilter[2 * dstY + 1]; yuv2packed1(c, *lumSrcPtr, chrUSrcPtr, chrVSrcPtr, alpPixBuf ? *alpSrcPtr : NULL, dest[0], dstW, chrAlpha, dstY); } else if (c->yuv2packed2 && vLumFilterSize == 2 && vChrFilterSize == 2) { int lumAlpha = vLumFilter[2 * dstY + 1]; int chrAlpha = vChrFilter[2 * dstY + 1]; lumMmxFilter[2] = lumMmxFilter[3] = vLumFilter[2 * dstY ] * 0x10001; chrMmxFilter[2] = chrMmxFilter[3] = vChrFilter[2 * chrDstY] * 0x10001; yuv2packed2(c, lumSrcPtr, chrUSrcPtr, chrVSrcPtr, alpPixBuf ? alpSrcPtr : NULL, dest[0], dstW, lumAlpha, chrAlpha, dstY); } else { yuv2packedX(c, vLumFilter + dstY * vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter + dstY * vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, alpSrcPtr, dest[0], dstW, dstY); } } } } if (isPlanar(dstFormat) && isALPHA(dstFormat) && !alpPixBuf) fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255); #if HAVE_MMX2 if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2) __asm__ volatile("sfence":::"memory"); #endif emms_c(); c->dstY= dstY; c->lumBufIndex= lumBufIndex; c->chrBufIndex= chrBufIndex; c->lastInLumBuf= lastInLumBuf; c->lastInChrBuf= lastInChrBuf; return dstY - lastDstY; }
1threat
I am new to python programming and I need help in finding numbers less than the number the user has entered with loops. How do I do that? : With this code, I only get to test if the number the user entered is prime or not. How do I add another loop to this code in order to find all the prime numbers less than or equal to the number the user has entered? num = int(input("Enter a number: ")) for x in range(1, num): if x > 1: prime = True for n in range(2, x): if (x % n) == 0: print ("Number", num, "is not prime") break else: print("Number", num, "is prime")
0debug
remove or \r in javscript or C# : how can I remove or replace \r in javascript text or in backend code in C# I have a variable in javascript like this : var text=name\r\hi\r\ > \r means line break or next line I try to this apporach to replace : text=text.replace("r",","); but dosent work
0debug
Passing arguments from one script to another, in a script : <p>I am trying to pass a python script variables from another python script in a python script. What I am trying to do in code form:</p> <p>file1.py</p> <pre><code>global x x = 7 </code></pre> <p>file2.py</p> <pre><code>print x </code></pre> <p>file3.py</p> <pre><code>import file1 import file2 </code></pre> <p>But I always get the error x is not defined. If I import file1 in file2 and run it, it works, but if I run file2 from file3 it does not work.</p> <p>Help would be much appreciated :)</p>
0debug
How to upload file to AWS S3 using AWS AppSync : <p>Following <a href="https://docs.aws.amazon.com/appsync/latest/devguide/building-a-client-app-react.html#complex-objects" rel="noreferrer">this docs/tutorial</a> in AWS AppSync Docs.</p> <p>It states:</p> <blockquote> <p>With AWS AppSync you can model these as GraphQL types. If any of your mutations have a variable with bucket, key, region, mimeType and localUri fields, the SDK will upload the file to Amazon S3 for you.</p> </blockquote> <p>However, I cannot make my file to upload to my s3 bucket. I understand that tutorial missing a lot of details. More specifically, the tutorial does not say that the <code>NewPostMutation.js</code> needs to be changed.</p> <p>I changed it the following way:</p> <pre><code>import gql from 'graphql-tag'; export default gql` mutation AddPostMutation($author: String!, $title: String!, $url: String!, $content: String!, $file: S3ObjectInput ) { addPost( author: $author title: $title url: $url content: $content file: $file ){ __typename id author title url content version } } ` </code></pre> <p>Yet, even after I have implemented these changes, the file did not get uploaded...</p>
0debug
static int mlp_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { MLPParseContext *mp = s->priv_data; int sync_present; uint8_t parity_bits; int next; int i, p = 0; *poutbuf_size = 0; if (buf_size == 0) return 0; if (!mp->in_sync) { for (i = 0; i < buf_size; i++) { mp->pc.state = (mp->pc.state << 8) | buf[i]; if ((mp->pc.state & 0xfffffffe) == 0xf8726fba && mp->pc.index + i >= 7) { mp->in_sync = 1; mp->bytes_left = 0; break; } } if (!mp->in_sync) { if (ff_combine_frame(&mp->pc, END_NOT_FOUND, &buf, &buf_size) != -1) av_log(avctx, AV_LOG_WARNING, "ff_combine_frame failed\n"); return buf_size; } ff_combine_frame(&mp->pc, i - 7, &buf, &buf_size); return i - 7; } if (mp->bytes_left == 0) { for(; mp->pc.overread>0; mp->pc.overread--) { mp->pc.buffer[mp->pc.index++]= mp->pc.buffer[mp->pc.overread_index++]; } if (mp->pc.index + buf_size < 2) { if (ff_combine_frame(&mp->pc, END_NOT_FOUND, &buf, &buf_size) != -1) av_log(avctx, AV_LOG_WARNING, "ff_combine_frame failed\n"); return buf_size; } mp->bytes_left = ((mp->pc.index > 0 ? mp->pc.buffer[0] : buf[0]) << 8) | (mp->pc.index > 1 ? mp->pc.buffer[1] : buf[1-mp->pc.index]); mp->bytes_left = (mp->bytes_left & 0xfff) * 2; if (mp->bytes_left <= 0) { goto lost_sync; } mp->bytes_left -= mp->pc.index; } next = (mp->bytes_left > buf_size) ? END_NOT_FOUND : mp->bytes_left; if (ff_combine_frame(&mp->pc, next, &buf, &buf_size) < 0) { mp->bytes_left -= buf_size; return buf_size; } mp->bytes_left = 0; sync_present = (AV_RB32(buf + 4) & 0xfffffffe) == 0xf8726fba; if (!sync_present) { parity_bits = 0; for (i = -1; i < mp->num_substreams; i++) { parity_bits ^= buf[p++]; parity_bits ^= buf[p++]; if (i < 0 || buf[p-2] & 0x80) { parity_bits ^= buf[p++]; parity_bits ^= buf[p++]; } } if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) { av_log(avctx, AV_LOG_INFO, "mlpparse: Parity check failed.\n"); goto lost_sync; } } else { GetBitContext gb; MLPHeaderInfo mh; init_get_bits(&gb, buf + 4, (buf_size - 4) << 3); if (ff_mlp_read_major_sync(avctx, &mh, &gb) < 0) goto lost_sync; avctx->bits_per_raw_sample = mh.group1_bits; if (avctx->bits_per_raw_sample > 16) avctx->sample_fmt = AV_SAMPLE_FMT_S32; else avctx->sample_fmt = AV_SAMPLE_FMT_S16; avctx->sample_rate = mh.group1_samplerate; s->duration = mh.access_unit_size; if(!avctx->channels || !avctx->channel_layout) { if (mh.stream_type == 0xbb) { #if FF_API_REQUEST_CHANNELS FF_DISABLE_DEPRECATION_WARNINGS if (avctx->request_channels > 0 && avctx->request_channels <= 2 && mh.num_substreams > 1) { avctx->channels = 2; avctx->channel_layout = AV_CH_LAYOUT_STEREO; FF_ENABLE_DEPRECATION_WARNINGS } else #endif if (avctx->request_channel_layout && (avctx->request_channel_layout & AV_CH_LAYOUT_STEREO) == avctx->request_channel_layout && mh.num_substreams > 1) { avctx->channels = 2; avctx->channel_layout = AV_CH_LAYOUT_STEREO; } else { avctx->channels = mh.channels_mlp; avctx->channel_layout = mh.channel_layout_mlp; } } else { #if FF_API_REQUEST_CHANNELS FF_DISABLE_DEPRECATION_WARNINGS if (avctx->request_channels > 0 && avctx->request_channels <= 2 && mh.num_substreams > 1) { avctx->channels = 2; avctx->channel_layout = AV_CH_LAYOUT_STEREO; } else if (avctx->request_channels > 0 && avctx->request_channels <= mh.channels_thd_stream1) { avctx->channels = mh.channels_thd_stream1; avctx->channel_layout = mh.channel_layout_thd_stream1; FF_ENABLE_DEPRECATION_WARNINGS } else #endif if (avctx->request_channel_layout && (avctx->request_channel_layout & AV_CH_LAYOUT_STEREO) == avctx->request_channel_layout && mh.num_substreams > 1) { avctx->channels = 2; avctx->channel_layout = AV_CH_LAYOUT_STEREO; } else if (!mh.channels_thd_stream2 || (avctx->request_channel_layout && (avctx->request_channel_layout & mh.channel_layout_thd_stream1) == avctx->request_channel_layout)) { avctx->channels = mh.channels_thd_stream1; avctx->channel_layout = mh.channel_layout_thd_stream1; } else { avctx->channels = mh.channels_thd_stream2; avctx->channel_layout = mh.channel_layout_thd_stream2; } } } if (!mh.is_vbr) avctx->bit_rate = mh.peak_bitrate; mp->num_substreams = mh.num_substreams; } *poutbuf = buf; *poutbuf_size = buf_size; return next; lost_sync: mp->in_sync = 0; return 1; }
1threat
want to get the value of array key : <p>I have a complicated array and want to find the value of this. but the problem is answer getting like 0,1,2,3,4,5</p> <p>following is the code to getting the value of state of array</p> <pre><code>var shardState = Object.keys(mydata.cluster.collections[collectionName].shards[String(shardName)].state); alert(shardState); </code></pre> <p>Following is the array.</p> <pre><code>{ "responseHeader":{ "status":0, "QTime":4}, "cluster":{ "collections":{ "college":{ "pullReplicas":"0", "replicationFactor":"1", "shards":{"shard1":{ "range":"80000000-7fffffff", "state":"active", </code></pre>
0debug
static int cpu_x86_fill_model_id(char *str) { uint32_t eax, ebx, ecx, edx; int i; for (i = 0; i < 3; i++) { host_cpuid(0x80000002 + i, 0, &eax, &ebx, &ecx, &edx); memcpy(str + i * 16 + 0, &eax, 4); memcpy(str + i * 16 + 4, &ebx, 4); memcpy(str + i * 16 + 8, &ecx, 4); memcpy(str + i * 16 + 12, &edx, 4); } return 0; }
1threat
Why is sub class' static code getting executed? : <p>I have written the following code and created object for the super class.</p> <pre><code>class SuperClass{ static int a=2; static int b(){ return 2; } int c(){ return 2; } SuperClass(){ System.out.println("Super"); } static { System.out.println("super"); } } public class Sub extends SuperClass{ Sub(){ System.out.println("Sub"); } static { System.out.println("sub"); } static int b(){ return 3; } int c(){ return 3; } public static void main(String ax[]){ SuperClass f =new SuperClass(); System.out.println(f.c()); System.out.print(SuperClass.b()); } } </code></pre> <p>When I checked the output, it is as follows:</p> <pre><code>super sub Super 2 2 </code></pre> <p>I know that static block is executed only when object of the class is initialized or any static reference is made. But here, i did not make any of these to Sub class. then why do i see "sub" i.e. sub class' static block output?</p>
0debug
Jira - Auto-Calculate Estimate based on story point : <p>Is there a way within Jira that I can auto assign an Estimate value when I assign Story points to an issue? </p> <p>As a business we get great use out of both - but I'm finding it slightly annoying to have to enter the data in multiple places. </p> <p>Understood that Agile is less about actual time values - and Story points are best practice - but just wondering if there's a plugin or setting that would allow me to enter 20 Story points -for example- and that issue be assigned an 8hr Estimate automatically.</p>
0debug
PIP 10.0.1 - Warning "Consider adding this directory to PATH or..." : <pre><code>The script flake8.exe is installed in 'c:\users\me\appdata\local\programs\python\python36-32\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. </code></pre> <p>Did some research on this and it seems like some sort of recurring issue. </p> <p>One fix recommends removing trailing slashes from the environment variable.</p> <p>Any other ideas?</p> <p>This occurs every time I install via PIP</p> <p>I am running python 3.6</p>
0debug
getElementById returns an object instead of an element : <p>I have an input with an id of <code>name</code>:</p> <pre><code>&lt;input type="text" id="name"&gt; </code></pre> <p>When I run <code>document.getElementById("name")</code> in the console, I get the element itself (<code>&lt;input type="text" id="name"&gt;</code>), but as soon as I assign it to a variable (<code>var name = document.getElementById("name");</code>), I get the string <code>"[object HTMLInputElement]"</code>.</p> <p>Why does that happen? Why can't I just get the selected input element, instead of the input element object?</p> <p>Thanks.</p>
0debug
static int get_int8(QEMUFile *f, void *pv, size_t size) { int8_t *v = pv; qemu_get_s8s(f, v); return 0; }
1threat
How to set the root directory for Visual Studio Code Python Extension? : <p>I have no trouble running and debugging my project with VSCode Python Extension (<code>ms-python.python</code>), but since python sub-project root directory is not the whole project directory, all imports from my sources are underlined with red color and are listed in the <code>problems</code> and so <code>Go to definition</code> and some similar features don't work properly. How can I tell the IDE where's the start point of my project:</p> <pre><code>Whole Project path: docs server entities user.py customer.py env viewer db </code></pre> <p>The <code>server</code> directory is where the imports path are started from:</p> <pre><code>from entities.user import User </code></pre>
0debug
why is smalltalk the second most love programming language : <p><a href="https://i.stack.imgur.com/8AegY.png" rel="nofollow noreferrer">smalltalk second most loved</a></p> <p>What is smalltalk used for that makes it so popular? Where can I learn some basic smalltalk?</p>
0debug
Wordpress: plugin generated 11 characters of unexpected output during the activation : <p>I use Wordpress and my plugin generated 11 characters of unexpected display during the activation but i don't know why. I'm I trying to activate the plugin and to generate the table on Workbench.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php if(!class_exists('Test')){ $inst_test = new Test(); } if(isset($inst_test)){ register_activation_hook(__FILE__, array($inst_test, 'test_install')); } class Test { function test_install(){ global $wpdb; $table_site = $wpdb-&gt;prefix.'test'; if($wpdb-&gt;get_var("SHOW TABLES LIKE '$table_site'") != $table_site) { $sql = "CREATE TABLE `$table_site'( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `nom` VARCHAR(255) NOT NULL, `title` VARCHAR(255) NOT NULL, `subtitle` VARCHAR(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; require_once(ABSPATH.'wp-admin/includes/upgrade.php'); dbDelta($sql); } } }?&gt;</code></pre> </div> </div> </p>
0debug
Keras (Tensorflow backend) slower on GPU than on CPU when training certain networks : <p>I am having some difficulty understanding exactly why the GPU and CPU speeds are similar with networks of small size (CPU is sometimes faster), and GPU is faster with networks of larger size. The code at the bottom of the question runs in 103.7s on an i7-6700k, but when using tensorflow-gpu, the code runs in 29.5 seconds.</p> <p>However, when I train a network that has 100 hidden neurons, instead of 1000 like in the example below, I get ~20 seconds when using the GPU, and ~15 seconds when using the CPU.</p> <p>I read on another stack overflow answer that CPU->GPU transfers take long, I'm assuming this is in reference to loading the data examples on the GPU.</p> <p>Can someone explain why this occurs, and possibly reference some change in the code that I can make to maximize speed?</p> <pre><code>import numpy as np import tensorflow as tf import keras from keras.models import Sequential from keras.utils import np_utils from keras.layers.core import Dense, Activation, Flatten, Dropout from sklearn.preprocessing import normalize ## Importing the MNIST dataset using Keras from keras.datasets import mnist (X_train, y_train), (X_test, y_test) = mnist.load_data() # reshape for vector input N, x, y = X_train.shape X_train = normalize(np.reshape(X_train, (N, x * y))) N, x, y = X_test.shape X_test = normalize(np.reshape(X_test, (N, x * y))) # one-hot encoding y_train = np_utils.to_categorical(y_train) y_test = np_utils.to_categorical(y_test) model = Sequential() model.add(Dense(output_dim=750, input_dim=784)) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(150)) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(50)) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(50)) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(10)) model.add(Activation('softmax')) model.compile(loss='categorical_crossentropy', optimizer='Nadam', metrics=['accuracy']) fit = model.fit(X_train, y_train, batch_size=128, nb_epoch=10, verbose=0) ## Printing the accuracy of our model, according to the loss function specified in model.compile above score = model.evaluate(X_test, y_test, verbose=0) print('Test score:', score[0]) print('Test accuracy:', score[1]) </code></pre>
0debug
How do I return to a previous step after throwing an exception rather than from the beginning of my program? : The code I'm working on is a main method to test a class called Triangle that takes two doubles and is used to calculate the hypotenuse of a triangle. My code is set up to throw exceptions whenever the inputs of the doubles are negative, not a number or zero. However, whenever an exception is thrown it prompts me to input the command again which is not desired. Once the command is entered it should prompt the user to input a value for the length of the side, and if the input double doesn't meet the criteria then it should ask the user to input a valid double for the length of the side. Thanks ahead for the help! My code is as follows: import java.util.InputMismatchException; import java.util.Scanner; public class Main { public static void main(String[] args) { Double sideA = null; Double sideB = null; Scanner scanner = new Scanner(System.in); while (true) { System.out.println("Enter command: "); String command = scanner.nextLine(); try { // checks command, throws exception if not A, B, C or Q if (command.equals("A")) { System.out.println("Enter a value for side A:"); sideA = scanner.nextDouble(); // throws InputMismatchException if not a double scanner.nextLine(); try { if (sideA < 0 || sideA == 0.0) { throw new InputMismatchException(); } } catch (InputMismatchException e) { System.out.println("Value is invalid. Must be positve and a double."); } } else if (command.equals("B")) { System.out.println("Enter a value for side B:"); sideB = scanner.nextDouble(); // throws InputMismatchException if not a double scanner.nextLine(); try { if (sideB < 0 || sideB == 0.0) { throw new InputMismatchException(); } } catch (InputMismatchException e) { System.out.println("Value is invalid. Must be positive and a double."); } } else if (command.equals("C")) { Triangle calculate = new Triangle(sideA, sideB); System.out.println(calculate.calcHypotenuse()); break; } else if (command.equals("Q")) { System.exit(0); } else { throw new IllegalArgumentException(); } } catch (IllegalArgumentException e) { System.out.println("Command is invalid, Enter A, B, C, or Q."); } catch (InputMismatchException e) { System.out.println("Value is invalid. Must be positve and a double."); scanner.nextLine(); } } } }
0debug
Parse poisson function in javascript to php : <p>I have the next code in javascript:</p> <pre><code>var exponential = 2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642742746; var numerator, denominator; function fact(x) { if(x==0) { return 1; } return x * fact(x-1); } function poisson(k, landa) { exponentialPower = Math.pow(exponential, -landa); // negative power k landaPowerK = Math.pow(landa, k); // Landa elevated k numerator = exponentialPower * landaPowerK; denominator = fact(k); // factorial of k. return (numerator / denominator); } </code></pre> <p>I need parse to php but i don't know how...</p> <p>Can somebody help me?</p>
0debug
int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, struct image_info * info) { struct elfhdr elf_ex; struct elfhdr interp_elf_ex; struct exec interp_ex; int interpreter_fd = -1; abi_ulong load_addr, load_bias; int load_addr_set = 0; unsigned int interpreter_type = INTERPRETER_NONE; unsigned char ibcs2_interpreter; int i; abi_ulong mapped_addr; struct elf_phdr * elf_ppnt; struct elf_phdr *elf_phdata; abi_ulong k, elf_brk; int retval; char * elf_interpreter; abi_ulong elf_entry, interp_load_addr = 0; int status; abi_ulong start_code, end_code, start_data, end_data; abi_ulong reloc_func_desc = 0; abi_ulong elf_stack; char passed_fileno[6]; ibcs2_interpreter = 0; status = 0; load_addr = 0; load_bias = 0; elf_ex = *((struct elfhdr *) bprm->buf); bswap_ehdr(&elf_ex); if ((elf_ex.e_type != ET_EXEC && elf_ex.e_type != ET_DYN) || (! elf_check_arch(elf_ex.e_machine))) { return -ENOEXEC; } bprm->p = copy_elf_strings(1, &bprm->filename, bprm->page, bprm->p); bprm->p = copy_elf_strings(bprm->envc,bprm->envp,bprm->page,bprm->p); bprm->p = copy_elf_strings(bprm->argc,bprm->argv,bprm->page,bprm->p); if (!bprm->p) { retval = -E2BIG; } elf_phdata = (struct elf_phdr *)malloc(elf_ex.e_phentsize*elf_ex.e_phnum); if (elf_phdata == NULL) { return -ENOMEM; } i = elf_ex.e_phnum * sizeof(struct elf_phdr); if (elf_ex.e_phoff + i <= BPRM_BUF_SIZE) { memcpy(elf_phdata, bprm->buf + elf_ex.e_phoff, i); } else { retval = pread(bprm->fd, (char *) elf_phdata, i, elf_ex.e_phoff); if (retval != i) { perror("load_elf_binary"); exit(-1); } } bswap_phdr(elf_phdata, elf_ex.e_phnum); elf_brk = 0; elf_stack = ~((abi_ulong)0UL); elf_interpreter = NULL; start_code = ~((abi_ulong)0UL); end_code = 0; start_data = 0; end_data = 0; interp_ex.a_info = 0; elf_ppnt = elf_phdata; for(i=0;i < elf_ex.e_phnum; i++) { if (elf_ppnt->p_type == PT_INTERP) { if ( elf_interpreter != NULL ) { free (elf_phdata); free(elf_interpreter); close(bprm->fd); return -EINVAL; } elf_interpreter = (char *)malloc(elf_ppnt->p_filesz); if (elf_interpreter == NULL) { free (elf_phdata); close(bprm->fd); return -ENOMEM; } if (elf_ppnt->p_offset + elf_ppnt->p_filesz <= BPRM_BUF_SIZE) { memcpy(elf_interpreter, bprm->buf + elf_ppnt->p_offset, elf_ppnt->p_filesz); } else { retval = pread(bprm->fd, elf_interpreter, elf_ppnt->p_filesz, elf_ppnt->p_offset); if (retval != elf_ppnt->p_filesz) { perror("load_elf_binary2"); exit(-1); } } if (strcmp(elf_interpreter,"/usr/lib/libc.so.1") == 0 || strcmp(elf_interpreter,"/usr/lib/ld.so.1") == 0) { ibcs2_interpreter = 1; } retval = open(path(elf_interpreter), O_RDONLY); if (retval < 0) { perror(elf_interpreter); exit(-1); } interpreter_fd = retval; retval = read(interpreter_fd, bprm->buf, BPRM_BUF_SIZE); if (retval < 0) { perror("load_elf_binary3"); exit(-1); } if (retval < BPRM_BUF_SIZE) { memset(bprm->buf, 0, BPRM_BUF_SIZE - retval); } interp_ex = *((struct exec *) bprm->buf); interp_elf_ex = *((struct elfhdr *) bprm->buf); } elf_ppnt++; } if (elf_interpreter){ interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT; if ((N_MAGIC(interp_ex) != OMAGIC) && (N_MAGIC(interp_ex) != ZMAGIC) && (N_MAGIC(interp_ex) != QMAGIC)) { interpreter_type = INTERPRETER_ELF; } if (interp_elf_ex.e_ident[0] != 0x7f || strncmp((char *)&interp_elf_ex.e_ident[1], "ELF",3) != 0) { interpreter_type &= ~INTERPRETER_ELF; } if (!interpreter_type) { free(elf_interpreter); free(elf_phdata); close(bprm->fd); return -ELIBBAD; } } { char * passed_p; if (interpreter_type == INTERPRETER_AOUT) { snprintf(passed_fileno, sizeof(passed_fileno), "%d", bprm->fd); passed_p = passed_fileno; if (elf_interpreter) { bprm->p = copy_elf_strings(1,&passed_p,bprm->page,bprm->p); bprm->argc++; } } if (!bprm->p) { if (elf_interpreter) { free(elf_interpreter); } free (elf_phdata); close(bprm->fd); return -E2BIG; } } info->end_data = 0; info->end_code = 0; info->start_mmap = (abi_ulong)ELF_START_MMAP; info->mmap = 0; elf_entry = (abi_ulong) elf_ex.e_entry; #if defined(CONFIG_USE_GUEST_BASE) if (!(have_guest_base || reserved_va)) { abi_ulong app_start = ~0; abi_ulong app_end = 0; abi_ulong addr; unsigned long host_start; unsigned long real_start; unsigned long host_size; for (i = 0, elf_ppnt = elf_phdata; i < elf_ex.e_phnum; i++, elf_ppnt++) { if (elf_ppnt->p_type != PT_LOAD) continue; addr = elf_ppnt->p_vaddr; if (addr < app_start) { app_start = addr; } addr += elf_ppnt->p_memsz; if (addr > app_end) { app_end = addr; } } assert(app_start < app_end); app_start = app_start & qemu_host_page_mask; app_end = HOST_PAGE_ALIGN(app_end); if (app_start < mmap_min_addr) { host_start = HOST_PAGE_ALIGN(mmap_min_addr); } else { host_start = app_start; if (host_start != app_start) { fprintf(stderr, "qemu: Address overflow loading ELF binary\n"); abort(); } } host_size = app_end - app_start; while (1) { real_start = (unsigned long)mmap((void *)host_start, host_size, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 0); if (real_start == (unsigned long)-1) { fprintf(stderr, "qemu: Virtual memory exausted\n"); abort(); } if (real_start == host_start) { break; } munmap((void *)real_start, host_size); host_start += qemu_host_page_size; if (host_start == app_start) { fprintf(stderr, "qemu: Unable to find space for application\n"); abort(); } } qemu_log("Relocating guest address space from 0x" TARGET_ABI_FMT_lx " to 0x%lx\n", app_start, real_start); guest_base = real_start - app_start; } #endif info->rss = 0; bprm->p = setup_arg_pages(bprm->p, bprm, info); info->start_stack = bprm->p; for(i = 0, elf_ppnt = elf_phdata; i < elf_ex.e_phnum; i++, elf_ppnt++) { int elf_prot = 0; int elf_flags = 0; abi_ulong error; if (elf_ppnt->p_type != PT_LOAD) continue; if (elf_ppnt->p_flags & PF_R) elf_prot |= PROT_READ; if (elf_ppnt->p_flags & PF_W) elf_prot |= PROT_WRITE; if (elf_ppnt->p_flags & PF_X) elf_prot |= PROT_EXEC; elf_flags = MAP_PRIVATE | MAP_DENYWRITE; if (elf_ex.e_type == ET_EXEC || load_addr_set) { elf_flags |= MAP_FIXED; } else if (elf_ex.e_type == ET_DYN) { error = target_mmap(0, ET_DYN_MAP_SIZE, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); if (error == -1) { perror("mmap"); exit(-1); } load_bias = TARGET_ELF_PAGESTART(error - elf_ppnt->p_vaddr); } error = target_mmap(TARGET_ELF_PAGESTART(load_bias + elf_ppnt->p_vaddr), (elf_ppnt->p_filesz + TARGET_ELF_PAGEOFFSET(elf_ppnt->p_vaddr)), elf_prot, (MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE), bprm->fd, (elf_ppnt->p_offset - TARGET_ELF_PAGEOFFSET(elf_ppnt->p_vaddr))); if (error == -1) { perror("mmap"); exit(-1); } #ifdef LOW_ELF_STACK if (TARGET_ELF_PAGESTART(elf_ppnt->p_vaddr) < elf_stack) elf_stack = TARGET_ELF_PAGESTART(elf_ppnt->p_vaddr); #endif if (!load_addr_set) { load_addr_set = 1; load_addr = elf_ppnt->p_vaddr - elf_ppnt->p_offset; if (elf_ex.e_type == ET_DYN) { load_bias += error - TARGET_ELF_PAGESTART(load_bias + elf_ppnt->p_vaddr); load_addr += load_bias; reloc_func_desc = load_bias; } } k = elf_ppnt->p_vaddr; if (k < start_code) start_code = k; if (start_data < k) start_data = k; k = elf_ppnt->p_vaddr + elf_ppnt->p_filesz; if ((elf_ppnt->p_flags & PF_X) && end_code < k) end_code = k; if (end_data < k) end_data = k; k = elf_ppnt->p_vaddr + elf_ppnt->p_memsz; if (k > elf_brk) { elf_brk = TARGET_PAGE_ALIGN(k); } if (elf_ppnt->p_filesz < elf_ppnt->p_memsz) { abi_ulong base = load_bias + elf_ppnt->p_vaddr; zero_bss(base + elf_ppnt->p_filesz, base + elf_ppnt->p_memsz, elf_prot); } } elf_entry += load_bias; elf_brk += load_bias; start_code += load_bias; end_code += load_bias; start_data += load_bias; end_data += load_bias; if (elf_interpreter) { if (interpreter_type & 1) { elf_entry = load_aout_interp(&interp_ex, interpreter_fd); } else if (interpreter_type & 2) { elf_entry = load_elf_interp(&interp_elf_ex, interpreter_fd, &interp_load_addr, bprm->buf); } reloc_func_desc = interp_load_addr; close(interpreter_fd); free(elf_interpreter); if (elf_entry == ~((abi_ulong)0UL)) { printf("Unable to load interpreter\n"); free(elf_phdata); exit(-1); return 0; } } free(elf_phdata); if (qemu_log_enabled()) { load_symbols(&elf_ex, bprm->fd, load_bias); } if (interpreter_type != INTERPRETER_AOUT) close(bprm->fd); info->personality = (ibcs2_interpreter ? PER_SVR4 : PER_LINUX); #ifdef LOW_ELF_STACK info->start_stack = bprm->p = elf_stack - 4; #endif bprm->p = create_elf_tables(bprm->p, bprm->argc, bprm->envc, &elf_ex, load_addr, load_bias, interp_load_addr, (interpreter_type == INTERPRETER_AOUT ? 0 : 1), info); info->load_addr = reloc_func_desc; info->start_brk = info->brk = elf_brk; info->end_code = end_code; info->start_code = start_code; info->start_data = start_data; info->end_data = end_data; info->start_stack = bprm->p; #if 0 printf("(start_brk) %x\n" , info->start_brk); printf("(end_code) %x\n" , info->end_code); printf("(start_code) %x\n" , info->start_code); printf("(end_data) %x\n" , info->end_data); printf("(start_stack) %x\n" , info->start_stack); printf("(brk) %x\n" , info->brk); #endif if ( info->personality == PER_SVR4 ) { mapped_addr = target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, -1, 0); } info->entry = elf_entry; #ifdef USE_ELF_CORE_DUMP bprm->core_dump = &elf_core_dump; #endif return 0; }
1threat
How can I compile this program in C with Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC : <p>Hello everyone Im triying to compile a C program correctly, but when I run the program throw the Error Ivalid Argument.</p> <p>Im tried to put the architecture type like -xarch=sparc or -m64 but nothing</p> <pre><code>bash-3.2$ cc -c Prueba.c -o Prueba.o -xarch=sparc bash-3.2$ chmod 777 Prueba.o bash-3.2$ ./Prueba.o bash: ./Prueba.o: Invalid argument bash-3.2$ cat /etc/release Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved. Assembled 17 January 2013 </code></pre>
0debug
Can I run Windows on a server? : <p>I want a Windows machine to act as a server, being able to open ports to clients and send data to them over the Internet.</p> <p>Is it possible to install Windows on any server to act like it or should I purchase Windows Server?</p> <p>I have never truly worked with servers before so I know my questions is silly. :) Thanks for response.</p>
0debug
static void dnxhd_decode_dct_block_8(const DNXHDContext *ctx, RowContext *row, int n) { dnxhd_decode_dct_block(ctx, row, n, 4, 32, 6); }
1threat
How to upload and read CSV files in React.js? : <p>I would like the user to upload a .csv file, and then have the browser be able to parse the data from that file. I am using ReactJS. How would this work? Thanks.</p>
0debug
how select field work when we have multiple and we can choose only one second will b disable according to choose item : how to choose one field in select box if one will choose second one will be disable and if second one will choose than first one will be disable how it will work help me for that `<select> </select>' or '<select> </select>`
0debug
static av_cold int init(AVFilterContext *ctx, const char *args0) { PanContext *const pan = ctx->priv; char *arg, *arg0, *tokenizer, *args = av_strdup(args0); int out_ch_id, in_ch_id, len, named, ret; int nb_in_channels[2] = { 0, 0 }; double gain; if (!args0) { av_log(ctx, AV_LOG_ERROR, "pan filter needs a channel layout and a set " "of channels definitions as parameter\n"); return AVERROR(EINVAL); } if (!args) return AVERROR(ENOMEM); arg = av_strtok(args, ":", &tokenizer); ret = ff_parse_channel_layout(&pan->out_channel_layout, arg, ctx); if (ret < 0) return ret; pan->nb_output_channels = av_get_channel_layout_nb_channels(pan->out_channel_layout); while ((arg = arg0 = av_strtok(NULL, ":", &tokenizer))) { if (parse_channel_name(&arg, &out_ch_id, &named)) { av_log(ctx, AV_LOG_ERROR, "Expected out channel name, got \"%.8s\"\n", arg); return AVERROR(EINVAL); } if (named) { if (!((pan->out_channel_layout >> out_ch_id) & 1)) { av_log(ctx, AV_LOG_ERROR, "Channel \"%.8s\" does not exist in the chosen layout\n", arg0); return AVERROR(EINVAL); } out_ch_id = av_get_channel_layout_nb_channels(pan->out_channel_layout & (((int64_t)1 << out_ch_id) - 1)); } if (out_ch_id < 0 || out_ch_id >= pan->nb_output_channels) { av_log(ctx, AV_LOG_ERROR, "Invalid out channel name \"%.8s\"\n", arg0); return AVERROR(EINVAL); } if (*arg == '=') { arg++; } else if (*arg == '<') { pan->need_renorm |= (int64_t)1 << out_ch_id; arg++; } else { av_log(ctx, AV_LOG_ERROR, "Syntax error after channel name in \"%.8s\"\n", arg0); return AVERROR(EINVAL); } while (1) { gain = 1; if (sscanf(arg, " %lf %n* %n", &gain, &len, &len)) arg += len; if (parse_channel_name(&arg, &in_ch_id, &named)){ av_log(ctx, AV_LOG_ERROR, "Expected in channel name, got \"%.8s\"\n", arg); return AVERROR(EINVAL); } nb_in_channels[named]++; if (nb_in_channels[!named]) { av_log(ctx, AV_LOG_ERROR, "Can not mix named and numbered channels\n"); return AVERROR(EINVAL); } pan->gain[out_ch_id][in_ch_id] = gain; if (!*arg) break; if (*arg != '+') { av_log(ctx, AV_LOG_ERROR, "Syntax error near \"%.8s\"\n", arg); return AVERROR(EINVAL); } arg++; skip_spaces(&arg); } } pan->need_renumber = !!nb_in_channels[1]; av_free(args); return 0; }
1threat
static int mov_read_trun(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { MOVFragment *frag = &c->fragment; AVStream *st = NULL; MOVStreamContext *sc; uint64_t offset; int64_t dts; int data_offset = 0; unsigned entries, first_sample_flags = frag->flags; int flags, distance, i; for (i = 0; i < c->fc->nb_streams; i++) { if (c->fc->streams[i]->id == frag->track_id) { st = c->fc->streams[i]; break; } } if (!st) { av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %d\n", frag->track_id); return -1; } sc = st->priv_data; if (sc->pseudo_stream_id+1 != frag->stsd_id) return 0; get_byte(pb); flags = get_be24(pb); entries = get_be32(pb); dprintf(c->fc, "flags 0x%x entries %d\n", flags, entries); if (flags & 0x001) data_offset = get_be32(pb); if (flags & 0x004) first_sample_flags = get_be32(pb); if (flags & 0x800) { MOVStts *ctts_data; if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data)) return -1; ctts_data = av_realloc(sc->ctts_data, (entries+sc->ctts_count)*sizeof(*sc->ctts_data)); if (!ctts_data) return AVERROR(ENOMEM); sc->ctts_data = ctts_data; } dts = st->duration; offset = frag->base_data_offset + data_offset; distance = 0; dprintf(c->fc, "first sample flags 0x%x\n", first_sample_flags); for (i = 0; i < entries; i++) { unsigned sample_size = frag->size; int sample_flags = i ? frag->flags : first_sample_flags; unsigned sample_duration = frag->duration; int keyframe; if (flags & 0x100) sample_duration = get_be32(pb); if (flags & 0x200) sample_size = get_be32(pb); if (flags & 0x400) sample_flags = get_be32(pb); if (flags & 0x800) { sc->ctts_data[sc->ctts_count].count = 1; sc->ctts_data[sc->ctts_count].duration = get_be32(pb); sc->ctts_count++; } if ((keyframe = st->codec->codec_type == CODEC_TYPE_AUDIO || (flags & 0x004 && !i && !sample_flags) || sample_flags & 0x2000000)) distance = 0; av_add_index_entry(st, offset, dts, sample_size, distance, keyframe ? AVINDEX_KEYFRAME : 0); dprintf(c->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", " "size %d, distance %d, keyframe %d\n", st->index, sc->sample_count+i, offset, dts, sample_size, distance, keyframe); distance++; assert(sample_duration % sc->time_rate == 0); dts += sample_duration / sc->time_rate; offset += sample_size; } frag->moof_offset = offset; sc->sample_count = st->nb_index_entries; st->duration = dts; return 0; }
1threat
static always_inline void gen_store_mem (DisasContext *ctx, void (*tcg_gen_qemu_store)(TCGv t0, TCGv t1, int flags), int ra, int rb, int32_t disp16, int fp, int clear, int local) { TCGv addr; if (local) addr = tcg_temp_local_new(TCG_TYPE_I64); else addr = tcg_temp_new(TCG_TYPE_I64); if (rb != 31) { tcg_gen_addi_i64(addr, cpu_ir[rb], disp16); if (clear) tcg_gen_andi_i64(addr, addr, ~0x7); } else { if (clear) disp16 &= ~0x7; tcg_gen_movi_i64(addr, disp16); } if (ra != 31) { if (fp) tcg_gen_qemu_store(cpu_fir[ra], addr, ctx->mem_idx); else tcg_gen_qemu_store(cpu_ir[ra], addr, ctx->mem_idx); } else { TCGv zero; if (local) zero = tcg_const_local_i64(0); else zero = tcg_const_i64(0); tcg_gen_qemu_store(zero, addr, ctx->mem_idx); tcg_temp_free(zero); } tcg_temp_free(addr); }
1threat
Expected a file name : <p>So basically, I was looking at this source code to try and edit it and learn from it, but I'm constantly getting an "Expected a file name" error (E0013) With any source code that I attempt to use... Error is on the first line (using scripts\codescripts\struct) "scripts"</p> <pre><code>#using scripts\codescripts\struct; #using scripts\shared\callbacks_shared; #using scripts\shared\system_shared; #insert scripts\shared\shared.gsh; #namespace clientids; REGISTER_SYSTEM("clientids", &amp;__init__, undefined) function __init__() { callback::on_start_gametype(&amp;init); callback::on_connect(&amp;on_player_connect); callback::on_spawned(&amp;on_player_spawned); } </code></pre>
0debug
Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document' : <pre><code>'&lt;button id="'+item['id']+'" class="btnDeactivateKeyInChildPremiumCustomer waves-effect waves-light&gt;ok&lt;/button&gt;' </code></pre> <p>I used above code for generating button inside of jquery each function.The button created dynamically and when i clicked the button , it should show the progress on the button. Im using this <a href="https://github.com/hakimel/Ladda" rel="noreferrer">Ladda Button Loader</a>.</p> <pre><code> btnDeactivateKeyInChildPremiumCustomerClick : function(event){ var id = event.currentTarget.id; var btnProgress = Ladda.create(document.querySelector('#'+id)); //btnProgress.start(); or //btnProgress.stop(); } </code></pre> <p>And then i passed the button the event handler catch the event process the above function.Inside that function it will create a <strong>btnProgress</strong> object. After that i can call start() or stop() functions.I have successfully worked the in the case of only one button without creating the button dynamically inside each . But in the for each case it is showing some errors while executing <strong>var btnProgress = Ladda.create(document.querySelector('#'+id));</strong></p> <p><strong>Error</strong></p> <pre><code>Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document': '#22' is not a valid selector. </code></pre>
0debug
How do you make a dictionary inverse and then use that to swap letters in a string in Python : <p>quick explanation of what im trying to do. I've been wondering how to inverse a dictionary as im trying to make a Monoalphabetic cipher which will help me for a challenge soon. My aim after learning how to inverse a dictionary is to be able to use that to swap letters in a string.</p> <p>This is what i have right now not much at all but it would be awesome if someone could help me out as i've been trying for a long time but i have no idea how to.</p> <pre><code>dicta = { 'a': 'M', 'b': 'N', 'c': 'B', 'd': 'V', 'e': 'C', 'f': 'X', 'g': 'Z', 'h': 'A', 'i': 'S', 'j': 'D', 'k': 'F', 'l': 'G', 'm': 'H', 'n': 'J', 'o': 'K', 'p': 'L', 'q': 'P', 'r': 'O', 's': 'I', 't': 'U', 'u': 'Y', 'v': 'T', 'w': 'R', 'x': 'E', 'y': 'W', 'z': 'Q', ' ': ' ', } print(dicta) </code></pre>
0debug
Pandas DataFrame sort ignoring the case : <p>I have a Pandas dataframe in Python. The contents of the dataframe are from <a href="https://en.wikipedia.org/wiki/UK_Singles_Chart_records_and_statistics#Most_weeks_at_number_one" rel="noreferrer">here</a>. I modified the case of the first alphabet in the "Single" column slightly. Here is what I have:</p> <pre><code>import pandas as pd df = pd.read_csv('test.csv') print df Position Artist Single Year Weeks 1 Frankie Laine I Believe 1953 18 weeks 2 Bryan Adams I Do It for You 1991 16 weeks 3 Wet Wet Wet love Is All Around 1994 15 weeks 4 Drake (feat. Wizkid &amp; Kyla) One Dance 2016 15 weeks 5 Queen bohemian Rhapsody 1975/76 &amp; 1991/92 14 weeks 6 Slim Whitman Rose Marie 1955 11 weeks 7 Whitney Houston i Will Always Love You 1992 10 weeks </code></pre> <p>I would like to sort by the <strong>Single</strong> column in ascending order (a to z). When I run</p> <pre><code>df.sort_values(by='Single',inplace=True) </code></pre> <p>it seems that the sort is not able to combine upper and lowercase. Here is what I get:</p> <pre><code>Position Artist Single Year Weeks 1 Frankie Laine I Believe 1953 18 weeks 2 Bryan Adams I Do It for You 1991 16 weeks 4 Drake (feat. Wizkid &amp; Kyla) One Dance 2016 15 weeks 6 Slim Whitman Rose Marie 1955 11 weeks 5 Queen bohemian Rhapsody 1975/76 &amp; 1991/92 14 weeks 7 Whitney Houston i Will Always Love You 1992 10 weeks 3 Wet Wet Wet love Is All Around 1994 15 weeks </code></pre> <p>So, it is sorting by uppercase first and then performing a separate sort by lower case. I want a combined sort, regardless of the case of the starting alphabet in the <strong>Single</strong> column. The row with "bohemian Rhapsody" is in the wrong location after sorting. It should be first; instead it is appearing as the 5th row after the sort.</p> <p>Is there a way to do sort a Pandas DataFrame while ignoring the case of the text in the <strong>Single</strong> column?</p>
0debug
Can R Create a plot like this? : <p>The plot below (taken from a e-text book on statistics) shows some hypothetical data for TV advertising dollars and associated sales. A line is fitted for the data and then the error of each data point is shown. Is there a pre-created plot like this that exists either using the native plot() function or ggplot2?</p> <p><a href="https://i.stack.imgur.com/9NLgs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9NLgs.png" alt="enter image description here"></a></p>
0debug
static int mszh_decomp(unsigned char * srcptr, int srclen, unsigned char * destptr) { unsigned char *destptr_bak = destptr; unsigned char mask = 0; unsigned char maskbit = 0; unsigned int ofs, cnt; while (srclen > 0) { if (maskbit == 0) { mask = *(srcptr++); maskbit = 8; srclen--; continue; } if ((mask & (1 << (--maskbit))) == 0) { *(int*)destptr = *(int*)srcptr; srclen -= 4; destptr += 4; srcptr += 4; } else { ofs = *(srcptr++); cnt = *(srcptr++); ofs += cnt * 256;; cnt = ((cnt >> 3) & 0x1f) + 1; ofs &= 0x7ff; srclen -= 2; cnt *= 4; for (; cnt > 0; cnt--) { *(destptr) = *(destptr - ofs); destptr++; } } } return (destptr - destptr_bak); }
1threat
What is the difference between events and helpers? : <p>What is the difference between <code>Meteor.templateName.events</code> and <code>Meteor.templateName.helpers</code>.</p> <p>and how do I know which one I need to implement for my template?</p>
0debug
static av_cold int raw_close_decoder(AVCodecContext *avctx) { RawVideoContext *context = avctx->priv_data; av_freep(&context->buffer); return 0; }
1threat
static int video_open(VideoState *is) { int w,h; if (screen_width) { w = screen_width; h = screen_height; } else { w = default_width; h = default_height; } if (!window) { int flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE; if (!window_title) window_title = input_filename; if (is_full_screen) flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, flags); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); if (window) { SDL_RendererInfo info; renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); if (!renderer) { av_log(NULL, AV_LOG_WARNING, "Failed to initialize a hardware accelerated renderer: %s\n", SDL_GetError()); renderer = SDL_CreateRenderer(window, -1, 0); } if (renderer) { if (!SDL_GetRendererInfo(renderer, &info)) av_log(NULL, AV_LOG_VERBOSE, "Initialized %s renderer.\n", info.name); } } } else { SDL_SetWindowSize(window, w, h); } if (!window || !renderer) { av_log(NULL, AV_LOG_FATAL, "SDL: could not set video mode - exiting\n"); do_exit(is); } is->width = w; is->height = h; return 0; }
1threat
How can I select max TASK_ID and CREATED_DATE from below data? Have already tried using MAX and DISTINCT : I have this data: REFERENCE_NO TASK_ID CREATED_DATE 244038 83102 2020-01-14 09:23:21:000000 244038 83114 2020-01-14 09:23:21:867000
0debug
Parsing in Java : <p>I have a few, theoretical ideas, but I don't know the language well. We basically need to make a rudimentary lexical analyzer. I have most of the bits, but here's the context. The straight-forward question is at the end.</p> <p>I need to read in a line from the console, then see if parts match up with a symbol table, which includes the keywords: <code>"print [variable]"</code>, <code>"load [variable]"</code>, <code>"mem [variable]"</code>, <code>"sqrt"</code> and <code>"stop"</code>, as well as mathematical symbols.</p> <p>It also needs to recognise the variables on their own (such as <code>"c = a + b"</code> as well.)</p> <p>So...it's not that hard, in theory. You'd check the first character of the string matched up with keywords or variables. If they do, keep looping through that keyword or variable to check if it's the same string, up until you hit a space.</p> <p>To summarize: How do I check the characters of a read in string to compare to stuff in Java? </p>
0debug
HTML Password pattern with minimal requirements : I've a little problem with a pattern for a input password. I need that this has this pattern but I can't find any solution for this problem. The password value needs: - 8 characters minimal length. - Begin with a number. - Finish with a uppercase letter. Thanks a lot!
0debug
can frontend-maven-plugin use node, npm already installed? : <p>I am new using maven and frontend-maven-plugin. I understand that we can add this code to pom.xml to run grunt for example:</p> <pre><code> &lt;plugin&gt; &lt;groupId&gt;com.github.eirslett&lt;/groupId&gt; &lt;artifactId&gt;frontend-maven-plugin&lt;/artifactId&gt; &lt;!-- NB! Set &lt;version&gt; to the latest released version of frontend-maven-plugin, like in README.md --&gt; &lt;version&gt;@project.version@&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;install node and npm&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;install-node-and-npm&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;nodeVersion&gt;v5.3.0&lt;/nodeVersion&gt; &lt;npmVersion&gt;3.3.12&lt;/npmVersion&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;npm install&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;npm&lt;/goal&gt; &lt;/goals&gt; &lt;!-- Optional configuration which provides for running any npm command --&gt; &lt;configuration&gt; &lt;arguments&gt;install&lt;/arguments&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;npm run build&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;npm&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;arguments&gt;run build&lt;/arguments&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;grunt build&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;grunt&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;arguments&gt;--no-color&lt;/arguments&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre> <p>I actually installed node and npm on my server for example: node is installed under /opt/app/trss/nodejs, npm under /opt/app/trss/nodejs/npm how can this pom.xml use the node,npm installed on my server? Thanks</p>
0debug
Creating a List "C" in HASKELL, which is a specific Composition of A and B lists : Im just starting to learn Haskell, and I have to create a function "**composite**" that receives 2 lists A and B (with same type) as input and outputs a new list "C", which is a composition of both A and B, specifically - list C has to include only those pairs (x,z), where exists an **y**, that: - (x,**y**) is included in list A and - (**y**,z) is included in list B. an example: 1)input A is [(a, b)] and B is [(b,c), (b,d)] the result is [(a,c), (a,d)] 2)[(a, b), (e, b)] and [(b,c), (b,d)] result is [(a,c), (a,d), (e, c), (e,d)] 3)[(a, b), (a, d), (a, e)] and [(b,c), (d,c)] result is [(a,c)]
0debug
Dropzone Submit Button on Upload : <p>I want to add a button upload to my dropzone file uploader. currently it's uploading the file directly after selecting or dragging the file into the dropzone area. What I want to do is: 1. Select or drap file to be uploaded. 2. Validate 3. Hit or press the button upload to upload the file.</p> <p>N.B: File is only being uploaded after pressing the button upload.</p> <p>Here is my form</p> <pre><code>&lt;form id='frmTarget' name='dropzone' action='upload_files.php' class='dropzone'&gt; &lt;div class='fallback'&gt; &lt;input name='file' type='file' multiple /&gt; &lt;/div&gt; &lt;input id='refCampaignID' name='refCampaignID' type='hidden' value=\ "$rowCampaign-&gt;CampaignID\" /&gt; &lt;/form&gt; </code></pre> <p>Here is my JS</p> <pre><code>Dropzone.options.frmTarget = { url: 'upload_files.php', paramName: 'file', clickable: true, maxFilesize: 5, uploadMultiple: true, maxFiles: 2, addRemoveLinks: true, acceptedFiles: '.png,.jpg,.pdf', dictDefaultMessage: 'Upload your files here', success: function(file, response) { setTimeout(function() { $('#insert_pic_div').hide(); $('#startEditingDiv').show(); }, 2000); } }; </code></pre> <p>Here is my php post request</p> <pre><code> foreach ($_FILES["file"] as $key =&gt; $arrDetail) { foreach ($arrDetail as $index =&gt; $detail) { //print_rr($_FILES["file"][$key][$index]); $targetDir = "project_images/"; $fileName = $_FILES["file"]['name'][$index]; $targetFile = $targetDir.$fileName; if(move_uploaded_file($_FILES["file"]['tmp_name'][$index],$targetFile)) { $db = new ZoriDatabase("tblTarget", $_REQUEST["TargetID"], null, 0); $db-&gt;Fields["refCampaignID"] = $_REQUEST["refCampaignID"]; $db-&gt;Fields["strPicture"] = $fileName; $db-&gt;Fields["blnActive"] = 1; $db-&gt;Fields["strLastUser"] = $_SESSION[USER]-&gt;USERNAME; $result = $db-&gt;Save(); if($result-&gt;Error == 1){ return "Details not saved."; }else{ return "Details saved."; } }else{ return "File not uploaded."; } } } </code></pre>
0debug
char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int width, int height, void *log_ctx) { int ret; char *name = NULL; char *supported_type = NULL; int attached = 0; JNIEnv *env = NULL; struct JNIAMediaCodecListFields jfields = { 0 }; jobject format = NULL; jobject codec = NULL; jstring tmp = NULL; jobject info = NULL; jobject type = NULL; jobjectArray types = NULL; JNI_ATTACH_ENV_OR_RETURN(env, &attached, log_ctx, NULL); if ((ret = ff_jni_init_jfields(env, &jfields, jni_amediacodeclist_mapping, 0, log_ctx)) < 0) { goto done; } if (jfields.init_id && jfields.find_decoder_for_format_id) { tmp = ff_jni_utf_chars_to_jstring(env, mime, log_ctx); if (!tmp) { goto done; } format = (*env)->CallStaticObjectMethod(env, jfields.mediaformat_class, jfields.create_video_format_id, tmp, width, height); if (ff_jni_exception_check(env, 1, log_ctx) < 0) { goto done; } (*env)->DeleteLocalRef(env, tmp); tmp = NULL; codec = (*env)->NewObject(env, jfields.mediacodec_list_class, jfields.init_id, 0); if (ff_jni_exception_check(env, 1, log_ctx) < 0) { goto done; } tmp = (*env)->CallObjectMethod(env, codec, jfields.find_decoder_for_format_id, format); if (ff_jni_exception_check(env, 1, log_ctx) < 0) { goto done; } if (!tmp) { av_log(NULL, AV_LOG_ERROR, "Could not find decoder in media codec list " "for format { mime=%s width=%d height=%d }\n", mime, width, height); goto done; } name = ff_jni_jstring_to_utf_chars(env, tmp, log_ctx); if (!name) { goto done; } } else { int i; int codec_count; codec_count = (*env)->CallStaticIntMethod(env, jfields.mediacodec_list_class, jfields.get_codec_count_id); if (ff_jni_exception_check(env, 1, log_ctx) < 0) { goto done; } for(i = 0; i < codec_count; i++) { int j; int type_count; int is_encoder; info = (*env)->CallStaticObjectMethod(env, jfields.mediacodec_list_class, jfields.get_codec_info_at_id, i); if (ff_jni_exception_check(env, 1, log_ctx) < 0) { goto done; } types = (*env)->CallObjectMethod(env, info, jfields.get_supported_types_id); if (ff_jni_exception_check(env, 1, log_ctx) < 0) { goto done; } is_encoder = (*env)->CallBooleanMethod(env, info, jfields.is_encoder_id); if (ff_jni_exception_check(env, 1, log_ctx) < 0) { goto done; } if (is_encoder) { continue; } type_count = (*env)->GetArrayLength(env, types); for (j = 0; j < type_count; j++) { type = (*env)->GetObjectArrayElement(env, types, j); if (ff_jni_exception_check(env, 1, log_ctx) < 0) { goto done; } supported_type = ff_jni_jstring_to_utf_chars(env, type, log_ctx); if (!supported_type) { goto done; } if (!av_strcasecmp(supported_type, mime)) { jobject codec_name; codec_name = (*env)->CallObjectMethod(env, info, jfields.get_name_id); if (ff_jni_exception_check(env, 1, log_ctx) < 0) { goto done; } name = ff_jni_jstring_to_utf_chars(env, codec_name, log_ctx); if (!name) { goto done; } if (strstr(name, "OMX.google")) { av_freep(&name); continue; } } av_freep(&supported_type); } (*env)->DeleteLocalRef(env, info); info = NULL; (*env)->DeleteLocalRef(env, types); types = NULL; if (name) break; } } done: if (format) { (*env)->DeleteLocalRef(env, format); } if (codec) { (*env)->DeleteLocalRef(env, codec); } if (tmp) { (*env)->DeleteLocalRef(env, tmp); } if (info) { (*env)->DeleteLocalRef(env, info); } if (type) { (*env)->DeleteLocalRef(env, type); } if (types) { (*env)->DeleteLocalRef(env, types); } av_freep(&supported_type); ff_jni_reset_jfields(env, &jfields, jni_amediacodeclist_mapping, 0, log_ctx); JNI_DETACH_ENV(attached, log_ctx); return name; }
1threat
(Swift iOS) Getting all numbers below a certain integer : Quick Question. I was wondering how to be able to get all the numbers below a certain integer. So like if the number is 5, it should get 4,3,2,1,
0debug
static void glib_select_fill(int *max_fd, fd_set *rfds, fd_set *wfds, fd_set *xfds, uint32_t *cur_timeout) { GMainContext *context = g_main_context_default(); int i; int timeout = 0; g_main_context_prepare(context, &max_priority); n_poll_fds = g_main_context_query(context, max_priority, &timeout, poll_fds, ARRAY_SIZE(poll_fds)); g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds)); for (i = 0; i < n_poll_fds; i++) { GPollFD *p = &poll_fds[i]; if ((p->events & G_IO_IN)) { FD_SET(p->fd, rfds); *max_fd = MAX(*max_fd, p->fd); } if ((p->events & G_IO_OUT)) { FD_SET(p->fd, wfds); *max_fd = MAX(*max_fd, p->fd); } if ((p->events & G_IO_ERR)) { FD_SET(p->fd, xfds); *max_fd = MAX(*max_fd, p->fd); } } if (timeout >= 0 && timeout < *cur_timeout) { *cur_timeout = timeout; } }
1threat
What is wrong with this post? : Is there any typo error? I cannot find any! It is a simple crud application with slim framework I am using mysql database... slim version is 2.6.2 Image of postman: [![enter image description here][1]][1] // Adds a customer function addCustomer() { //$request = Slim::getInstance()->request(); $request = \Slim\Slim::getInstance()->request(); $cus = json_decode($request->getBody()); $sql = "INSERT INTO customers (Username,First_Name,Last_Name,Email,Phone,Password,Type,Status) VALUES (:username, :firstname, :lastname, :email, :phone, :password, :type, :status)"; try { $db = DB_Connection(); $stmt = $db->prepare($sql); $stmt->bindParam("username", $cus->Username); $stmt->bindParam("firstname", $cus->First_Name); $stmt->bindParam("lastname", $cus->Last_Name); $stmt->bindParam("email", $cus->Email); $stmt->bindParam("phone", $cus->Phone); $stmt->bindParam("password", $cus->Password); $stmt->bindParam("type", $cus->Type); $stmt->bindParam("status", $cus->Status); $stmt->execute(); $cus->id = $db->lastInsertId(); $db = null; echo json_encode($cus); } catch(PDOException $e) { echo '{"error":{"text":'. $e->getMessage() .'}}'; } } [![enter image description here][2]][2] [1]: http://i.stack.imgur.com/9zOAA.png [2]: http://i.stack.imgur.com/fckFM.png
0debug
Commit message with --no-verify with git kraken : <p>I want to ignore git hook in some scenario i have.</p> <p>How can i commit using <code>gitKraken</code> while specifying <code>--no-verify</code> flag.</p> <p>Thanks.</p>
0debug
make Ionic App visible only for mobile phone : my app does not have registration, how can I make it visible only for trusted mobile phone ? and How can I prevented to use my api publicly ?
0debug
void put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) { POWERPC_TBL_DECLARE(altivec_put_pixels16_num, 1); #ifdef ALTIVEC_USE_REFERENCE_C_CODE int i; POWERPC_TBL_START_COUNT(altivec_put_pixels16_num, 1); for(i=0; i<h; i++) { *((uint32_t*)(block )) = (((const struct unaligned_32 *) (pixels))->l); *((uint32_t*)(block+4)) = (((const struct unaligned_32 *) (pixels+4))->l); *((uint32_t*)(block+8)) = (((const struct unaligned_32 *) (pixels+8))->l); *((uint32_t*)(block+12)) = (((const struct unaligned_32 *) (pixels+12))->l); pixels+=line_size; block +=line_size; } POWERPC_TBL_STOP_COUNT(altivec_put_pixels16_num, 1); #else register vector unsigned char pixelsv1, pixelsv2; register vector unsigned char perm = vec_lvsl(0, pixels); int i; POWERPC_TBL_START_COUNT(altivec_put_pixels16_num, 1); for(i=0; i<h; i++) { pixelsv1 = vec_ld(0, (unsigned char*)pixels); pixelsv2 = vec_ld(16, (unsigned char*)pixels); vec_st(vec_perm(pixelsv1, pixelsv2, perm), 0, (unsigned char*)block); pixels+=line_size; block +=line_size; } POWERPC_TBL_STOP_COUNT(altivec_put_pixels16_num, 1); #endif }
1threat
How to generate 3 non repeated random numbers from a range? : <p>Using PHP, how can I select 3 numbers from a numbers range, that don't repeat theirselves?</p> <p>For example from a range 1 - 100, an answer may be 5, 32, 12, but not 5, 5, 93</p> <p>Thank you</p>
0debug
static int get_transform_coeffs1(uint8_t *exps, uint8_t *bap, float chcoeff, float *coeffs, int start, int end, int dith_flag, GetBitContext *gb, dither_state *state) { int16_t mantissa; int i; int gcode; mant_group l3_grp, l5_grp, l11_grp; for (i = 0; i < 3; i++) l3_grp.gcodes[i] = l5_grp.gcodes[i] = l11_grp.gcodes[i] = -1; l3_grp.gcptr = l5_grp.gcptr = 3; l11_grp.gcptr = 2; i = 0; while (i < start) coeffs[i++] = 0; for (i = start; i < end; i++) { switch (bap[i]) { case 0: if (!dith_flag) { coeffs[i] = 0; continue; } else { mantissa = dither_int16(state); coeffs[i] = to_float(exps[i], mantissa) * chcoeff; continue; } case 1: if (l3_grp.gcptr > 2) { gcode = get_bits(gb, 5); if (gcode > 26) return -1; l3_grp.gcodes[0] = gcode / 9; l3_grp.gcodes[1] = (gcode % 9) / 3; l3_grp.gcodes[2] = (gcode % 9) % 3; l3_grp.gcptr = 0; } mantissa = l3_q_tab[l3_grp.gcodes[l3_grp.gcptr++]]; coeffs[i] = to_float(exps[i], mantissa) * chcoeff; continue; case 2: if (l5_grp.gcptr > 2) { gcode = get_bits(gb, 7); if (gcode > 124) return -1; l5_grp.gcodes[0] = gcode / 25; l5_grp.gcodes[1] = (gcode % 25) / 5; l5_grp.gcodes[2] = (gcode % 25) % 5; l5_grp.gcptr = 0; } mantissa = l5_q_tab[l5_grp.gcodes[l5_grp.gcptr++]]; coeffs[i] = to_float(exps[i], mantissa) * chcoeff; continue; case 3: mantissa = get_bits(gb, 3); if (mantissa > 6) return -1; mantissa = l7_q_tab[mantissa]; coeffs[i] = to_float(exps[i], mantissa); continue; case 4: if (l11_grp.gcptr > 1) { gcode = get_bits(gb, 7); if (gcode > 120) return -1; l11_grp.gcodes[0] = gcode / 11; l11_grp.gcodes[1] = gcode % 11; } mantissa = l11_q_tab[l11_grp.gcodes[l11_grp.gcptr++]]; coeffs[i] = to_float(exps[i], mantissa) * chcoeff; continue; case 5: mantissa = get_bits(gb, 4); if (mantissa > 14) return -1; mantissa = l15_q_tab[mantissa]; coeffs[i] = to_float(exps[i], mantissa) * chcoeff; continue; default: mantissa = get_bits(gb, qntztab[bap[i]]) << (16 - qntztab[bap[i]]); coeffs[i] = to_float(exps[i], mantissa) * chcoeff; continue; } } i = end; while (i < 256) coeffs[i++] = 0; return 0; }
1threat
How can ı add new drawer items? but ı get exception : when ı add much more driwerItem ı get exception. How can ı fix. please help..:) https://github.com/flutter-tuts/drawer_demo
0debug
Where is documentation on Python's `set`'s class methods? : I gather that Python's built-in type `set` has a number of useful class methods, such as `set.intersection()`. Where are they documented? I haven't found them documented [here](https://docs.python.org/3.7/library/stdtypes.html?highlight=set#set), which seems to cover only the instance methods.
0debug
why i can not write subroutine between do and write? : [enter image description here][1] [enter image description here][2]com/UqpSq.png [1]: https://i.stack.imgur. [2]: https://i.stack.imgur.com/El05K.png
0debug
How are pointers derefrenced in C/C++? From addr to addr+size or addr-size on a modern linux machine? : If I have a pointer `p`. I want to read 4 bytes i.e data from `p` to `p+3` address. Will casting `p` to `int *` and dereferencing give me the data?
0debug
Python Waiting for a Button press and execute accordingly : from gpiozero import Button, LED from time import time, sleep from random import randint led = LED(17) btn = Button(27) while True: btn.wait_for_release() start = time() led.on() btn.wait_for_press() end = time() led.off() print(end-start, 'seconds') Hi I have got this working so far. Does any body know how to upgrade this to wait for the button press for a specific time( eg;5 mins)and if not pressed program executes another function. if pressed before 5 mins program stops
0debug
How to Default a program using c# : <p>I created a media player in winforms.i want to default it using c#.when you clicked an mp3 anywhere ,windows media player open that mp3file.i want to my program open files when double clicked on a mp3 or other files.</p> <p>I hope someone helps me.</p>
0debug
static void gen_neon_dup_u8(TCGv var, int shift) { TCGv tmp = new_tmp(); if (shift) tcg_gen_shri_i32(var, var, shift); tcg_gen_ext8u_i32(var, var); tcg_gen_shli_i32(tmp, var, 8); tcg_gen_or_i32(var, var, tmp); tcg_gen_shli_i32(tmp, var, 16); tcg_gen_or_i32(var, var, tmp); dead_tmp(tmp); }
1threat
How to exchange or return varibale values in different methods within same class in python? : <blockquote> <p>I want to pass a method value to to other method of the same class</p> </blockquote> <pre><code>class abc: def me(self): self.x = 5 def you(self): print('I want to print here -&gt; x = 5') if __name__ == '__main__': SR =abc() SR.you() </code></pre> <blockquote> <p>while calling the method 'you' how can I print the value of x, which is variable of other method</p> </blockquote>
0debug
static void build_pci_bus_end(PCIBus *bus, void *bus_state) { AcpiBuildPciBusHotplugState *child = bus_state; AcpiBuildPciBusHotplugState *parent = child->parent; GArray *bus_table = build_alloc_array(); DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX); DECLARE_BITMAP(slot_device_present, PCI_SLOT_MAX); DECLARE_BITMAP(slot_device_system, PCI_SLOT_MAX); DECLARE_BITMAP(slot_device_vga, PCI_SLOT_MAX); DECLARE_BITMAP(slot_device_qxl, PCI_SLOT_MAX); uint8_t op; int i; QObject *bsel; GArray *method; bool bus_hotplug_support = false; if (bus->parent_dev) { op = 0x82; build_append_nameseg(bus_table, "S%.02X_", bus->parent_dev->devfn); build_append_byte(bus_table, 0x08); build_append_nameseg(bus_table, "_SUN"); build_append_value(bus_table, PCI_SLOT(bus->parent_dev->devfn), 1); build_append_byte(bus_table, 0x08); build_append_nameseg(bus_table, "_ADR"); build_append_value(bus_table, (PCI_SLOT(bus->parent_dev->devfn) << 16) | PCI_FUNC(bus->parent_dev->devfn), 4); } else { op = 0x10; ; build_append_nameseg(bus_table, "PCI0"); } bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL); if (bsel) { build_append_byte(bus_table, 0x08); build_append_nameseg(bus_table, "BSEL"); build_append_int(bus_table, qint_get_int(qobject_to_qint(bsel))); memset(slot_hotplug_enable, 0xff, sizeof slot_hotplug_enable); } else { memset(slot_hotplug_enable, 0x00, sizeof slot_hotplug_enable); } memset(slot_device_present, 0x00, sizeof slot_device_present); memset(slot_device_system, 0x00, sizeof slot_device_present); memset(slot_device_vga, 0x00, sizeof slot_device_vga); memset(slot_device_qxl, 0x00, sizeof slot_device_qxl); for (i = 0; i < ARRAY_SIZE(bus->devices); i += PCI_FUNC_MAX) { DeviceClass *dc; PCIDeviceClass *pc; PCIDevice *pdev = bus->devices[i]; int slot = PCI_SLOT(i); if (!pdev) { continue; } set_bit(slot, slot_device_present); pc = PCI_DEVICE_GET_CLASS(pdev); dc = DEVICE_GET_CLASS(pdev); if (pc->class_id == PCI_CLASS_BRIDGE_ISA) { set_bit(slot, slot_device_system); } if (pc->class_id == PCI_CLASS_DISPLAY_VGA) { set_bit(slot, slot_device_vga); if (object_dynamic_cast(OBJECT(pdev), "qxl-vga")) { set_bit(slot, slot_device_qxl); } } if (!dc->hotpluggable || pc->is_bridge) { clear_bit(slot, slot_hotplug_enable); } } for (i = 0; i < PCI_SLOT_MAX; i++) { bool can_eject = test_bit(i, slot_hotplug_enable); bool present = test_bit(i, slot_device_present); bool vga = test_bit(i, slot_device_vga); bool qxl = test_bit(i, slot_device_qxl); bool system = test_bit(i, slot_device_system); if (can_eject) { void *pcihp = acpi_data_push(bus_table, ACPI_PCIHP_SIZEOF); memcpy(pcihp, ACPI_PCIHP_AML, ACPI_PCIHP_SIZEOF); patch_pcihp(i, pcihp); bus_hotplug_support = true; } else if (qxl) { void *pcihp = acpi_data_push(bus_table, ACPI_PCIQXL_SIZEOF); memcpy(pcihp, ACPI_PCIQXL_AML, ACPI_PCIQXL_SIZEOF); patch_pciqxl(i, pcihp); } else if (vga) { void *pcihp = acpi_data_push(bus_table, ACPI_PCIVGA_SIZEOF); memcpy(pcihp, ACPI_PCIVGA_AML, ACPI_PCIVGA_SIZEOF); patch_pcivga(i, pcihp); } else if (system) { } else if (present) { void *pcihp = acpi_data_push(bus_table, ACPI_PCINOHP_SIZEOF); memcpy(pcihp, ACPI_PCINOHP_AML, ACPI_PCINOHP_SIZEOF); patch_pcinohp(i, pcihp); } } if (bsel) { method = build_alloc_method("DVNT", 2); for (i = 0; i < PCI_SLOT_MAX; i++) { GArray *notify; uint8_t op; if (!test_bit(i, slot_hotplug_enable)) { continue; } notify = build_alloc_array(); op = 0xA0; build_append_byte(notify, 0x7B); build_append_byte(notify, 0x68); build_append_int(notify, 0x1 << i); build_append_byte(notify, 0x00); build_append_byte(notify, 0x86); build_append_nameseg(notify, "S%.02X_", PCI_DEVFN(i, 0)); build_append_byte(notify, 0x69); build_package(notify, op, 0); build_append_array(method, notify); build_free_array(notify); } build_append_and_cleanup_method(bus_table, method); } if (bus_hotplug_support || child->notify_table->len || !bus->parent_dev) { method = build_alloc_method("PCNT", 0); if (bsel) { build_append_byte(method, 0x70); build_append_int(method, qint_get_int(qobject_to_qint(bsel))); build_append_nameseg(method, "BNUM"); build_append_nameseg(method, "DVNT"); build_append_nameseg(method, "PCIU"); build_append_int(method, 1); build_append_nameseg(method, "DVNT"); build_append_nameseg(method, "PCID"); build_append_int(method, 3); } build_append_array(method, child->notify_table); build_append_and_cleanup_method(bus_table, method); build_append_array(bus_table, child->device_table); if (bus->parent_dev) { build_extop_package(bus_table, op); } else { build_package(bus_table, op, 0); } build_append_array(parent->device_table, bus_table); if (bus->parent_dev) { build_append_byte(parent->notify_table, '^'); build_append_byte(parent->notify_table, 0x2E); build_append_nameseg(parent->notify_table, "S%.02X_", bus->parent_dev->devfn); build_append_nameseg(parent->notify_table, "PCNT"); } } build_free_array(bus_table); build_pci_bus_state_cleanup(child); g_free(child); }
1threat
Random number always 0 : <p>I have a function that generates a number and i'm pushing it into my array, but the number generated is always 0, why ?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function generateId() { var randomNum = Math.floor((Math.random()*10) + 1); if(randomNum = ids.indexOf(randomNum)) { return generateId(); }; ids.push[randomNum]; return randomNum; };</code></pre> </div> </div> </p>
0debug