problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
void MPV_frame_end(MpegEncContext *s)
{
if (s->pict_type != B_TYPE && !s->intra_only) {
if(s->avctx==NULL || s->avctx->codec->id!=CODEC_ID_MPEG4 || s->divx_version==500){
draw_edges(s->current_picture[0], s->linesize, s->mb_width*16, s->mb_height*16, EDGE_WIDTH);
draw_edges(s->current_picture[1], s->linesize/2, s->mb_width*8, s->mb_height*8, EDGE_WIDTH/2);
draw_edges(s->current_picture[2], s->linesize/2, s->mb_width*8, s->mb_height*8, EDGE_WIDTH/2);
}else{
draw_edges(s->current_picture[0], s->linesize, s->width, s->height, EDGE_WIDTH);
draw_edges(s->current_picture[1], s->linesize/2, s->width/2, s->height/2, EDGE_WIDTH/2);
draw_edges(s->current_picture[2], s->linesize/2, s->width/2, s->height/2, EDGE_WIDTH/2);
}
}
emms_c();
if(s->pict_type!=B_TYPE){
s->last_non_b_pict_type= s->pict_type;
s->last_non_b_qscale= s->qscale;
s->last_non_b_mc_mb_var= s->mc_mb_var;
s->num_available_buffers++;
if(s->num_available_buffers>2) s->num_available_buffers= 2;
}
}
| 1threat
|
static void qemu_laio_process_completion(struct qemu_laiocb *laiocb)
{
int ret;
ret = laiocb->ret;
if (ret != -ECANCELED) {
if (ret == laiocb->nbytes) {
ret = 0;
} else if (ret >= 0) {
if (laiocb->is_read) {
qemu_iovec_memset(laiocb->qiov, ret, 0,
laiocb->qiov->size - ret);
} else {
ret = -ENOSPC;
}
}
}
laiocb->ret = ret;
if (laiocb->co) {
if (laiocb->co != qemu_coroutine_self()) {
qemu_coroutine_enter(laiocb->co);
}
} else {
laiocb->common.cb(laiocb->common.opaque, ret);
qemu_aio_unref(laiocb);
}
}
| 1threat
|
void usb_host_info(Monitor *mon, const QDict *qdict)
{
libusb_device **devs;
struct libusb_device_descriptor ddesc;
char port[16];
int i, n;
if (usb_host_init() != 0) {
return;
}
n = libusb_get_device_list(ctx, &devs);
for (i = 0; i < n; i++) {
if (libusb_get_device_descriptor(devs[i], &ddesc) != 0) {
continue;
}
if (ddesc.bDeviceClass == LIBUSB_CLASS_HUB) {
continue;
}
usb_host_get_port(devs[i], port, sizeof(port));
monitor_printf(mon, " Bus %d, Addr %d, Port %s, Speed %s Mb/s\n",
libusb_get_bus_number(devs[i]),
libusb_get_device_address(devs[i]),
port,
speed_name[libusb_get_device_speed(devs[i])]);
monitor_printf(mon, " Class %02x:", ddesc.bDeviceClass);
monitor_printf(mon, " USB device %04x:%04x",
ddesc.idVendor, ddesc.idProduct);
if (ddesc.iProduct) {
libusb_device_handle *handle;
if (libusb_open(devs[i], &handle) == 0) {
unsigned char name[64] = "";
libusb_get_string_descriptor_ascii(handle,
ddesc.iProduct,
name, sizeof(name));
libusb_close(handle);
monitor_printf(mon, ", %s", name);
}
}
monitor_printf(mon, "\n");
}
libusb_free_device_list(devs, 1);
}
| 1threat
|
static int64_t allocate_cluster(BlockDriverState *bs, int64_t sector_num)
{
BDRVParallelsState *s = bs->opaque;
uint32_t idx, offset, tmp;
int64_t pos;
int ret;
idx = sector_num / s->tracks;
offset = sector_num % s->tracks;
if (idx >= s->catalog_size) {
return -EINVAL;
}
if (s->catalog_bitmap[idx] != 0) {
return (uint64_t)s->catalog_bitmap[idx] * s->off_multiplier + offset;
}
pos = bdrv_getlength(bs->file) >> BDRV_SECTOR_BITS;
if (s->has_truncate) {
ret = bdrv_truncate(bs->file, (pos + s->tracks) << BDRV_SECTOR_BITS);
} else {
ret = bdrv_write_zeroes(bs->file, pos, s->tracks, 0);
}
if (ret < 0) {
return ret;
}
s->catalog_bitmap[idx] = pos / s->off_multiplier;
tmp = cpu_to_le32(s->catalog_bitmap[idx]);
ret = bdrv_pwrite(bs->file,
sizeof(ParallelsHeader) + idx * sizeof(tmp), &tmp, sizeof(tmp));
if (ret < 0) {
s->catalog_bitmap[idx] = 0;
return ret;
}
return (uint64_t)s->catalog_bitmap[idx] * s->off_multiplier + offset;
}
| 1threat
|
how to create android chat application without firebase? : <p>I want to create a chat program, without FireBase. Because Iran is sanctioned by Google.</p>
<p>I want users to send private messages to each other.</p>
<p>Please tell me how can I Create this project?</p>
| 0debug
|
Differences between Flash and HTML5 : <p>Since Youtube has dropped flash for HTML5, what exactly are the qualities/utilities that HTML5 possesses that makes it different than flash? </p>
<p>Also, I wish to know something more interesting(conceptually/technically) about the same (apart from what the normal google search is showing).</p>
| 0debug
|
Typescript: How do I define interfaces for nested objects? : <p>Assume I have a JSON payload that parses into something like this: </p>
<pre><code>{
name: "test",
items: {
"a": {
id: 1,
size: 10
},
"b": {
id: 2,
size: 34
}
}
}
</code></pre>
<p>How would I set up the definition of the Example interface to model that the value of the items property is an object whose keys are strings and whose values are defined by the Item interface:</p>
<pre><code>export interface Example {
name: string;
items: ???;
}
export interface Item {
id: number;
size: number;
}
</code></pre>
| 0debug
|
static int decode_pic(AVSContext *h)
{
int ret;
int skip_count = -1;
enum cavs_mb mb_type;
if (!h->top_qp) {
av_log(h->avctx, AV_LOG_ERROR, "No sequence header decoded yet\n");
return AVERROR_INVALIDDATA;
}
av_frame_unref(h->cur.f);
skip_bits(&h->gb, 16);
if (h->stc == PIC_PB_START_CODE) {
h->cur.f->pict_type = get_bits(&h->gb, 2) + AV_PICTURE_TYPE_I;
if (h->cur.f->pict_type > AV_PICTURE_TYPE_B) {
av_log(h->avctx, AV_LOG_ERROR, "illegal picture type\n");
return AVERROR_INVALIDDATA;
}
if (!h->DPB[0].f->data[0] ||
(!h->DPB[1].f->data[0] && h->cur.f->pict_type == AV_PICTURE_TYPE_B))
return AVERROR_INVALIDDATA;
} else {
h->cur.f->pict_type = AV_PICTURE_TYPE_I;
if (get_bits1(&h->gb))
skip_bits(&h->gb, 24);
if (h->low_delay || !(show_bits(&h->gb, 9) & 1))
h->stream_revision = 1;
else if (show_bits(&h->gb, 11) & 3)
h->stream_revision = 1;
if (h->stream_revision > 0)
skip_bits(&h->gb, 1);
}
ret = ff_get_buffer(h->avctx, h->cur.f, h->cur.f->pict_type == AV_PICTURE_TYPE_B ?
0 : AV_GET_BUFFER_FLAG_REF);
if (ret < 0)
return ret;
if (!h->edge_emu_buffer) {
int alloc_size = FFALIGN(FFABS(h->cur.f->linesize[0]) + 32, 32);
h->edge_emu_buffer = av_mallocz(alloc_size * 2 * 24);
if (!h->edge_emu_buffer)
return AVERROR(ENOMEM);
}
if ((ret = ff_cavs_init_pic(h)) < 0)
return ret;
h->cur.poc = get_bits(&h->gb, 8) * 2;
if (h->cur.f->pict_type != AV_PICTURE_TYPE_B) {
h->dist[0] = (h->cur.poc - h->DPB[0].poc) & 511;
} else {
h->dist[0] = (h->DPB[0].poc - h->cur.poc) & 511;
}
h->dist[1] = (h->cur.poc - h->DPB[1].poc) & 511;
h->scale_den[0] = h->dist[0] ? 512/h->dist[0] : 0;
h->scale_den[1] = h->dist[1] ? 512/h->dist[1] : 0;
if (h->cur.f->pict_type == AV_PICTURE_TYPE_B) {
h->sym_factor = h->dist[0] * h->scale_den[1];
if (FFABS(h->sym_factor) > 32768) {
av_log(h->avctx, AV_LOG_ERROR, "sym_factor %d too large\n", h->sym_factor);
return AVERROR_INVALIDDATA;
}
} else {
h->direct_den[0] = h->dist[0] ? 16384 / h->dist[0] : 0;
h->direct_den[1] = h->dist[1] ? 16384 / h->dist[1] : 0;
}
if (h->low_delay)
get_ue_golomb(&h->gb);
h->progressive = get_bits1(&h->gb);
h->pic_structure = 1;
if (!h->progressive)
h->pic_structure = get_bits1(&h->gb);
if (!h->pic_structure && h->stc == PIC_PB_START_CODE)
skip_bits1(&h->gb);
skip_bits1(&h->gb);
skip_bits1(&h->gb);
h->pic_qp_fixed =
h->qp_fixed = get_bits1(&h->gb);
h->qp = get_bits(&h->gb, 6);
if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) {
if (!h->progressive && !h->pic_structure)
skip_bits1(&h->gb);
skip_bits(&h->gb, 4);
} else {
if (!(h->cur.f->pict_type == AV_PICTURE_TYPE_B && h->pic_structure == 1))
h->ref_flag = get_bits1(&h->gb);
skip_bits(&h->gb, 4);
h->skip_mode_flag = get_bits1(&h->gb);
}
h->loop_filter_disable = get_bits1(&h->gb);
if (!h->loop_filter_disable && get_bits1(&h->gb)) {
h->alpha_offset = get_se_golomb(&h->gb);
h->beta_offset = get_se_golomb(&h->gb);
} else {
h->alpha_offset = h->beta_offset = 0;
}
if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) {
do {
check_for_slice(h);
decode_mb_i(h, 0);
} while (ff_cavs_next_mb(h));
} else if (h->cur.f->pict_type == AV_PICTURE_TYPE_P) {
do {
if (check_for_slice(h))
skip_count = -1;
if (h->skip_mode_flag && (skip_count < 0))
skip_count = get_ue_golomb(&h->gb);
if (h->skip_mode_flag && skip_count--) {
decode_mb_p(h, P_SKIP);
} else {
mb_type = get_ue_golomb(&h->gb) + P_SKIP + h->skip_mode_flag;
if (mb_type > P_8X8)
decode_mb_i(h, mb_type - P_8X8 - 1);
else
decode_mb_p(h, mb_type);
}
} while (ff_cavs_next_mb(h));
} else {
do {
if (check_for_slice(h))
skip_count = -1;
if (h->skip_mode_flag && (skip_count < 0))
skip_count = get_ue_golomb(&h->gb);
if (h->skip_mode_flag && skip_count--) {
decode_mb_b(h, B_SKIP);
} else {
mb_type = get_ue_golomb(&h->gb) + B_SKIP + h->skip_mode_flag;
if (mb_type > B_8X8)
decode_mb_i(h, mb_type - B_8X8 - 1);
else
decode_mb_b(h, mb_type);
}
} while (ff_cavs_next_mb(h));
}
emms_c();
if (h->cur.f->pict_type != AV_PICTURE_TYPE_B) {
av_frame_unref(h->DPB[1].f);
FFSWAP(AVSFrame, h->cur, h->DPB[1]);
FFSWAP(AVSFrame, h->DPB[0], h->DPB[1]);
}
return 0;
}
| 1threat
|
How i can set Toast message text from xml file : <p>Is there any way I can set <code>toast</code> text from <code>.xml</code>file?</p>
<p>for example :</p>
<pre><code> Toast.makeText(SmsManager.this,android.R.string.toast_text, Toast.LENGTH_SHORT).show();
</code></pre>
| 0debug
|
Config files for a script : <p>I have a script in bash in linux that is supposed to import data from csv into mysql database.
I need to make this script as generic as possible so I need to control it using config files that will specify which data goes to which table, etc. so that I don't change the script in the future when I need to make modifications to the tables for example.</p>
<p>How can I start and how can I do it ? as I am completely new to this topic.</p>
| 0debug
|
static int pci_piix3_xen_ide_unplug(DeviceState *dev)
{
PCIDevice *pci_dev;
PCIIDEState *pci_ide;
DriveInfo *di;
int i = 0;
pci_dev = DO_UPCAST(PCIDevice, qdev, dev);
pci_ide = DO_UPCAST(PCIIDEState, dev, pci_dev);
for (; i < 3; i++) {
di = drive_get_by_index(IF_IDE, i);
if (di != NULL && di->bdrv != NULL && !di->bdrv->removable) {
DeviceState *ds = bdrv_get_attached(di->bdrv);
if (ds) {
bdrv_detach(di->bdrv, ds);
}
bdrv_close(di->bdrv);
pci_ide->bus[di->bus].ifs[di->unit].bs = NULL;
drive_put_ref(di);
}
}
qdev_reset_all(&(pci_ide->dev.qdev));
return 0;
}
| 1threat
|
static QList *channel_list_get(void)
{
return NULL;
}
| 1threat
|
static int vnc_set_x509_credential(VncDisplay *vs,
const char *certdir,
const char *filename,
char **cred,
int ignoreMissing)
{
struct stat sb;
if (*cred) {
qemu_free(*cred);
*cred = NULL;
}
*cred = qemu_malloc(strlen(certdir) + strlen(filename) + 2);
strcpy(*cred, certdir);
strcat(*cred, "/");
strcat(*cred, filename);
VNC_DEBUG("Check %s\n", *cred);
if (stat(*cred, &sb) < 0) {
qemu_free(*cred);
*cred = NULL;
if (ignoreMissing && errno == ENOENT)
return 0;
return -1;
}
return 0;
}
| 1threat
|
Php compare data with a backslash to mysql one : get_magic_quotes_gpc() is 0;
if I replace other data like these
$replace[0]=">";
$replace[1]="<";
$replace[2]="&";
$replace[3]='"';
$pattern[0]="#>#";
$pattern[1]="#<#";
$pattern[2]="#&#";
$pattern[3]="#"#";
$pass=preg_replace($pattern, $replace, $pass);
it's works, but a backslash and a single qoute::
$replace[5]="\\";
$pattern[5]="/\/";
fail. php5.2
| 0debug
|
Linux command to extract single file from tar as bytes / byte array : <p>I want to extract a single file from tar file as bytes. </p>
<p>I'm aware of the command "tar -xf xyz.tar abc.pdf"</p>
<p>This extracts a physical file in the current location. But i want to extract directly as bytes or byte array.</p>
| 0debug
|
VPN over PPTP on mac os sierra : <p>Lately I discovered that connecting to a VPN via PPTP option has been removed in the new mac os - sierra.
I tried multiple application to do so - all failed.
How can I connect to my VPN over PPTP?</p>
<p>ps. I don't want to use L2TP because I don't have a pre shared key (I also don't know what it is).</p>
| 0debug
|
Is WPF ideal to create a midi editor windows desktop app? : <p>I'm planning to create a midi editor, like the <a href="https://i.stack.imgur.com/j3Hov.png" rel="nofollow noreferrer">piano roll</a> in DAWs like Reaper, Cubase, Fl Studio..
To get the midi data in, i will use NAudio's library. For the UI, i'm thinking WPF since that's the only framework i have experience with.</p>
<p>So my question is: Do i have much better options other than c# and wpf for this task? If so, what would it be and why?</p>
| 0debug
|
static int vda_h264_uninit(AVCodecContext *avctx)
{
VDAContext *vda = avctx->internal->hwaccel_priv_data;
av_freep(&vda->bitstream);
if (vda->frame)
CVPixelBufferRelease(vda->frame);
return 0;
}
| 1threat
|
IE 11 does not support method ‘from’ : <p>My 3000 lines of code execute just fine in chrome and Firefox with zero errors reported.</p>
<p>However, in IE11 (where the code MUST run), I get an error saying that the method ‘from’ is not supported at the following line:</p>
<pre><code>var inputsArray = Array.from(document.querySelectorAll('input.input' + b));
</code></pre>
<p>How can I resolve this?</p>
<p>The HTML file contains the correct compatibility mode for edge so that’s not the issue.</p>
| 0debug
|
List of numbers of intercetions : Hi I have 2 lists of list
c=[[1,2], [2,3]]
b=[[1,2], [2,0]]
I need for the first item in list c compare it with the first item in list b and
add to the new list number of intercetion - 2
Than do the same with second elements of two lists and so on.
As a result - list of numbers of intercetion [2, 1...]
def intercect (l1,l2,count):
count=0
for i in l1:
if i in(l2): count=count+1.0
return count
c=[[1,2], [2,3]]
b=[[1,2], [2,0]]
count1=[]
count=0
for i in c:
for j in b:
count1.append(intercect(i,j,0))
| 0debug
|
How to use openCV's connected components with stats in python? : <p>I am looking for an example of how to use OpenCV's ConnectedComponentsWithStats() function in python, note this is only available with OpenCV 3 or newer. The official documentation only shows the API for C++, even though the function exists when compiled for python. I could not find it anywhere online.</p>
| 0debug
|
static int mjpegb_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
UINT8 *buf, int buf_size)
{
MJpegDecodeContext *s = avctx->priv_data;
UINT8 *buf_end, *buf_ptr;
int i;
AVPicture *picture = data;
GetBitContext hgb;
uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs;
uint32_t field_size;
*data_size = 0;
if (buf_size == 0)
return 0;
buf_ptr = buf;
buf_end = buf + buf_size;
read_header:
s->restart_interval = 0;
init_get_bits(&hgb, buf_ptr, buf_end - buf_ptr);
skip_bits(&hgb, 32);
if (get_bits(&hgb, 32) != be2me_32(ff_get_fourcc("mjpg")))
{
dprintf("not mjpeg-b (bad fourcc)\n");
return 0;
}
field_size = get_bits(&hgb, 32);
dprintf("field size: 0x%x\n", field_size);
skip_bits(&hgb, 32);
second_field_offs = get_bits(&hgb, 32);
dprintf("second field offs: 0x%x\n", second_field_offs);
if (second_field_offs)
s->interlaced = 1;
dqt_offs = get_bits(&hgb, 32);
dprintf("dqt offs: 0x%x\n", dqt_offs);
if (dqt_offs)
{
init_get_bits(&s->gb, buf+dqt_offs, buf_end - (buf+dqt_offs));
s->start_code = DQT;
mjpeg_decode_dqt(s);
}
dht_offs = get_bits(&hgb, 32);
dprintf("dht offs: 0x%x\n", dht_offs);
if (dht_offs)
{
init_get_bits(&s->gb, buf+dht_offs, buf_end - (buf+dht_offs));
s->start_code = DHT;
mjpeg_decode_dht(s);
}
sof_offs = get_bits(&hgb, 32);
dprintf("sof offs: 0x%x\n", sof_offs);
if (sof_offs)
{
init_get_bits(&s->gb, buf+sof_offs, buf_end - (buf+sof_offs));
s->start_code = SOF0;
if (mjpeg_decode_sof0(s) < 0)
return -1;
}
sos_offs = get_bits(&hgb, 32);
dprintf("sos offs: 0x%x\n", sos_offs);
if (sos_offs)
{
init_get_bits(&s->gb, buf+sos_offs, field_size);
s->start_code = SOS;
mjpeg_decode_sos(s);
}
skip_bits(&hgb, 32);
if (s->interlaced) {
s->bottom_field ^= 1;
if (s->bottom_field && second_field_offs)
{
buf_ptr = buf + second_field_offs;
second_field_offs = 0;
goto read_header;
}
}
for(i=0;i<3;i++) {
picture->data[i] = s->current_picture[i];
picture->linesize[i] = (s->interlaced) ?
s->linesize[i] >> 1 : s->linesize[i];
}
*data_size = sizeof(AVPicture);
avctx->height = s->height;
if (s->interlaced)
avctx->height *= 2;
avctx->width = s->width;
switch((s->h_count[0] << 4) | s->v_count[0]) {
case 0x11:
avctx->pix_fmt = PIX_FMT_YUV444P;
break;
case 0x21:
avctx->pix_fmt = PIX_FMT_YUV422P;
break;
default:
case 0x22:
avctx->pix_fmt = PIX_FMT_YUV420P;
break;
}
return buf_ptr - buf;
}
| 1threat
|
Observable<{}> not assignable to type Observable<SomeType[]> : <p>I'm learning Angular2 and Typescript. I'm working through the Heroes tutorial on angular.io, but applying it to a project I'm converting from ASP.Net. I've run into a problem which I think is due to my lack of understanding, though as far as I can see it matches what the relevant part of the tutorial is doing.</p>
<pre><code>import { Injectable } from '@angular/core';
import {RiskListSummary} from '../Models/RiskListSummary';
import { Observable } from 'rxjs/Rx';
import { Http, Response } from '@angular/http';
@Injectable()
export class RiskAssessmentListService {
constructor(private http : Http) {}
private serviceUrl = "http://myserviceurl/";
getRisks(): Observable<RiskListSummary[]> {
return this.http.get(this.serviceUrl)
.map(this.extractData())
.catch(this.handleError());
}
private extractData(res: Response) {
if (res.status < 200 || res.status >= 300) {
throw new Error('Bad response status: ' + res.status);
}
let body = res.json();
return body.data || { };
}
private handleError (error: any) {
let errMsg = error.message || 'Server error';
console.error(errMsg); // log to console instead
return Observable.throw(errMsg);
}
}
</code></pre>
<p>I'm getting the following error on the line "return this.http.get(this.serviceUrl)":</p>
<blockquote>
<p>Error:(20, 16) TS2322: Type 'Observable<{}>' is not assignable to type
'Observable'. Type '{}' is not assignable to type
'RiskListSummary[]'. Property 'length' is missing in type '{}'.</p>
</blockquote>
<p>If it makes a difference, I'm using webstorm (latest version), but I think this error is coming straight from the typescript compiler. I was thinking maybe I need a typings file for rxjs, but the tutorial doesn't use one, and none of the ones that I found with a "typings search" made a difference</p>
<p>The following are my dependencies from package.json:</p>
<pre><code> "dependencies": {
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.1",
"@angular/upgrade": "2.0.0-rc.1",
"systemjs": "0.19.27",
"es6-shim": "^0.35.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12"
</code></pre>
| 0debug
|
static void libschroedinger_handle_first_access_unit(AVCodecContext *avctx)
{
SchroDecoderParams *p_schro_params = avctx->priv_data;
SchroDecoder *decoder = p_schro_params->decoder;
p_schro_params->format = schro_decoder_get_video_format(decoder);
if (av_image_check_size(p_schro_params->format->width,
p_schro_params->format->height, 0, avctx) < 0) {
av_log(avctx, AV_LOG_ERROR, "invalid dimensions (%dx%d)\n",
p_schro_params->format->width, p_schro_params->format->height);
avctx->height = avctx->width = 0;
return;
}
avctx->height = p_schro_params->format->height;
avctx->width = p_schro_params->format->width;
avctx->pix_fmt = get_chroma_format(p_schro_params->format->chroma_format);
if (ff_get_schro_frame_format(p_schro_params->format->chroma_format,
&p_schro_params->frame_format) == -1) {
av_log(avctx, AV_LOG_ERROR,
"This codec currently only supports planar YUV 4:2:0, 4:2:2 "
"and 4:4:4 formats.\n");
return;
}
avctx->framerate.num = p_schro_params->format->frame_rate_numerator;
avctx->framerate.den = p_schro_params->format->frame_rate_denominator;
}
| 1threat
|
static void vp8_release_frame(VP8Context *s, AVFrame *f, int is_close)
{
if (!is_close) {
if (f->ref_index[0]) {
assert(s->num_maps_to_be_freed < FF_ARRAY_ELEMS(s->segmentation_maps));
s->segmentation_maps[s->num_maps_to_be_freed++] = f->ref_index[0];
f->ref_index[0] = NULL;
}
} else {
av_freep(&f->ref_index[0]);
}
ff_thread_release_buffer(s->avctx, f);
}
| 1threat
|
static void bt_l2cap_sdp_close_ch(void *opaque)
{
struct bt_l2cap_sdp_state_s *sdp = opaque;
int i;
for (i = 0; i < sdp->services; i ++) {
g_free(sdp->service_list[i].attribute_list->pair);
g_free(sdp->service_list[i].attribute_list);
g_free(sdp->service_list[i].uuid);
}
g_free(sdp->service_list);
g_free(sdp);
}
| 1threat
|
static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,
int drc_index, const char *drc_name,
void *fdt, int node_offset)
{
int offset, ret;
int slot = PCI_SLOT(dev->devfn);
int func = PCI_FUNC(dev->devfn);
char nodename[FDT_NAME_MAX];
if (func != 0) {
snprintf(nodename, FDT_NAME_MAX, "pci@%x,%x", slot, func);
} else {
snprintf(nodename, FDT_NAME_MAX, "pci@%x", slot);
}
offset = fdt_add_subnode(fdt, node_offset, nodename);
ret = spapr_populate_pci_child_dt(dev, fdt, offset, phb->index, drc_index,
phb);
g_assert(!ret);
if (ret) {
return 0;
}
return offset;
}
| 1threat
|
SQlite database contains " as char and how to retrive it as string : I have database of words which has " in the character.
I use Hotal.ttf fonts as my language doesnt have unicode support(yet).
Word in databse is: K"ME@ which looks like this: [![Oo ji matra][1]][1]
I am retrving this from android SQlite database and displaying it in text view.
here is the query code:
String searchQuery = "SELECT kMean FROM dictionary WHERE eName LIKE '%" + search + "%' LIMIT 1";
However it is retrived as this: [![enter image description here][2]][2]
So i think it takes ' instead of " and hance letter [![enter image description here][3]][3] is displayed insted of [![enter image description here][4]][4]
Help please.
[1]: https://i.stack.imgur.com/FXKeJ.jpg
[2]: https://i.stack.imgur.com/TBjMd.jpg
[3]: https://i.stack.imgur.com/Pb5i8.jpg
[4]: https://i.stack.imgur.com/NNcyr.jpg
| 0debug
|
static void cpu_unregister_map_client(void *_client)
{
MapClient *client = (MapClient *)_client;
QLIST_REMOVE(client, link);
g_free(client);
}
| 1threat
|
void ff_put_h264_qpel4_mc22_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_mid_4w_msa(src - (2 * stride) - 2, stride, dst, stride, 4);
}
| 1threat
|
void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque)
{
unsigned long size;
struct rlimit rlimit_as;
mapcache = g_malloc0(sizeof (MapCache));
mapcache->phys_offset_to_gaddr = f;
mapcache->opaque = opaque;
qemu_mutex_init(&mapcache->lock);
QTAILQ_INIT(&mapcache->locked_entries);
if (geteuid() == 0) {
rlimit_as.rlim_cur = RLIM_INFINITY;
rlimit_as.rlim_max = RLIM_INFINITY;
mapcache->max_mcache_size = MCACHE_MAX_SIZE;
} else {
getrlimit(RLIMIT_AS, &rlimit_as);
rlimit_as.rlim_cur = rlimit_as.rlim_max;
if (rlimit_as.rlim_max != RLIM_INFINITY) {
fprintf(stderr, "Warning: QEMU's maximum size of virtual"
" memory is not infinity.\n");
}
if (rlimit_as.rlim_max < MCACHE_MAX_SIZE + NON_MCACHE_MEMORY_SIZE) {
mapcache->max_mcache_size = rlimit_as.rlim_max -
NON_MCACHE_MEMORY_SIZE;
} else {
mapcache->max_mcache_size = MCACHE_MAX_SIZE;
}
}
setrlimit(RLIMIT_AS, &rlimit_as);
mapcache->nr_buckets =
(((mapcache->max_mcache_size >> XC_PAGE_SHIFT) +
(1UL << (MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT)) - 1) >>
(MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT));
size = mapcache->nr_buckets * sizeof (MapCacheEntry);
size = (size + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1);
DPRINTF("%s, nr_buckets = %lx size %lu\n", __func__,
mapcache->nr_buckets, size);
mapcache->entry = g_malloc0(size);
}
| 1threat
|
Is there a JQuery or Javascript warning message utility which shows and timeouts without interfering with the user : <p>I am looking for some non-modal warning messages which would stack on the right side of the screen and not interfere with the user working on the screen. I have forgotten that little utility name and where I can download it from. </p>
<p>Any help would be very appreciated...</p>
<p>DK</p>
| 0debug
|
static int spdif_get_offset_and_codec(AVFormatContext *s,
enum IEC61937DataType data_type,
const char *buf, int *offset,
enum AVCodecID *codec)
{
AACADTSHeaderInfo aac_hdr;
GetBitContext gbc;
switch (data_type & 0xff) {
case IEC61937_AC3:
*offset = AC3_FRAME_SIZE << 2;
*codec = AV_CODEC_ID_AC3;
break;
case IEC61937_MPEG1_LAYER1:
*offset = spdif_mpeg_pkt_offset[1][0];
*codec = AV_CODEC_ID_MP1;
break;
case IEC61937_MPEG1_LAYER23:
*offset = spdif_mpeg_pkt_offset[1][0];
*codec = AV_CODEC_ID_MP3;
break;
case IEC61937_MPEG2_EXT:
*offset = 4608;
*codec = AV_CODEC_ID_MP3;
break;
case IEC61937_MPEG2_AAC:
init_get_bits(&gbc, buf, AAC_ADTS_HEADER_SIZE * 8);
if (avpriv_aac_parse_header(&gbc, &aac_hdr)) {
if (s)
av_log(s, AV_LOG_ERROR, "Invalid AAC packet in IEC 61937\n");
return AVERROR_INVALIDDATA;
}
*offset = aac_hdr.samples << 2;
*codec = AV_CODEC_ID_AAC;
break;
case IEC61937_MPEG2_LAYER1_LSF:
*offset = spdif_mpeg_pkt_offset[0][0];
*codec = AV_CODEC_ID_MP1;
break;
case IEC61937_MPEG2_LAYER2_LSF:
*offset = spdif_mpeg_pkt_offset[0][1];
*codec = AV_CODEC_ID_MP2;
break;
case IEC61937_MPEG2_LAYER3_LSF:
*offset = spdif_mpeg_pkt_offset[0][2];
*codec = AV_CODEC_ID_MP3;
break;
case IEC61937_DTS1:
*offset = 2048;
*codec = AV_CODEC_ID_DTS;
break;
case IEC61937_DTS2:
*offset = 4096;
*codec = AV_CODEC_ID_DTS;
break;
case IEC61937_DTS3:
*offset = 8192;
*codec = AV_CODEC_ID_DTS;
break;
default:
if (s) {
avpriv_request_sample(s, "Data type 0x%04x in IEC 61937",
data_type);
}
return AVERROR_PATCHWELCOME;
}
return 0;
}
| 1threat
|
How do I resolve npm audit returning ENOAUDIT: Your configured registry does not support audit requests? : <p>This recently broke and I do not know what I might have done to break it beyond adding some additional dependencies. I am using <a href="https://registry.npmjs.org/" rel="noreferrer">https://registry.npmjs.org/</a> (the default). The relevant portion of the log file is below. Has anyone seen something similar? I've only seen this referenced in some old bug reports.</p>
<pre><code>6 info audit Submitting payload of 66980 bytes
7 http fetch POST 500 https://registry.npmjs.org/-/npm/v1/security/audits 548ms
8 verbose stack Error: Your configured registry (https://registry.npmjs.org/) does not support audit requests.
8 verbose stack at Bluebird.all.spread.then.catch (C:\Users\micha\AppData\Roaming\npm\node_modules\npm\lib\audit.js:172:18)
8 verbose stack at tryCatcher (C:\Users\micha\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
8 verbose stack at Promise._settlePromiseFromHandler (C:\Users\micha\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
8 verbose stack at Promise._settlePromise (C:\Users\micha\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
8 verbose stack at Promise._settlePromise0 (C:\Users\micha\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
8 verbose stack at Promise._settlePromises (C:\Users\micha\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:689:18)
8 verbose stack at Async._drainQueue (C:\Users\micha\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\async.js:133:16)
8 verbose stack at Async._drainQueues (C:\Users\micha\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\async.js:143:10)
8 verbose stack at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\micha\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\async.js:17:14)
8 verbose stack at runCallback (timers.js:694:18)
8 verbose stack at tryOnImmediate (timers.js:665:5)
8 verbose stack at processImmediate (timers.js:647:5)
9 verbose cwd C:\src\studio-template
10 verbose Windows_NT 10.0.17134
11 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\micha\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "audit"
12 verbose node v10.11.0
13 verbose npm v6.4.1
14 error code ENOAUDIT
15 error audit Your configured registry (https://registry.npmjs.org/) does not support audit requests.
</code></pre>
| 0debug
|
static int handle_hypercall(CPUState *env, struct kvm_run *run)
{
int r;
cpu_synchronize_state(env);
r = s390_virtio_hypercall(env);
kvm_arch_put_registers(env);
return r;
}
| 1threat
|
Python script to insert in sqlite table : <p>I am getting some data through user input and then I have to insert the same data in sqlite tables.</p>
<pre><code>conn = sqlite.connect('c:/sqlite/test.db')
c = conn.cursor()
c.execute("Select Max(person_id) from persons")
person_id =c.fetchone()[0]
person_name = input ("Please provide User Name: ")
user_id= input("Please user_id table: ")
home_floor = input ("Please provide home floor for user: ")
start_dt= input("Please enter start date (yyyy-mm-dd) for User : ")
end_dt = input ("Please enter end date (yyyy-mm-dd) for User: ")
c.execute('insert into Person values (%s,%s,%s,%s,%s,%s) person_id,person_name,user_id,home_floor,start_dt,end_dt)
</code></pre>
| 0debug
|
What is the cost of google cloud platform for Blaze plan? : <p>I am planning to use BigQuery for my mobile application, which will be using Firebase analytics data. What I understand from the docs is that I need to use Blaze plan in order to do that . I have followed this link . </p>
<p><a href="https://firebase.google.com/pricing/" rel="nofollow noreferrer">https://firebase.google.com/pricing/</a></p>
<p>In the link below in that page ,there is a calculator for blaze plan,but that calculator does not include "Google Cloud Platform" option for calculation. So can someone explain how does the pricing for that works ? Or is it that the data part under cloud functions mean the same ? So the amount of data depicting user hits and parameters amount to that 5Gb free downloadable data ?
Thanks :)</p>
| 0debug
|
static uint32_t bonito_sbridge_pciaddr(void *opaque, hwaddr addr)
{
PCIBonitoState *s = opaque;
PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
uint32_t cfgaddr;
uint32_t idsel;
uint32_t devno;
uint32_t funno;
uint32_t regno;
uint32_t pciaddr;
if ((s->regs[BONITO_PCIMAP_CFG] & 0x10000) != 0x0) {
return 0xffffffff;
}
cfgaddr = addr & 0xffff;
cfgaddr |= (s->regs[BONITO_PCIMAP_CFG] & 0xffff) << 16;
idsel = (cfgaddr & BONITO_PCICONF_IDSEL_MASK) >> BONITO_PCICONF_IDSEL_OFFSET;
devno = ffs(idsel) - 1;
funno = (cfgaddr & BONITO_PCICONF_FUN_MASK) >> BONITO_PCICONF_FUN_OFFSET;
regno = (cfgaddr & BONITO_PCICONF_REG_MASK) >> BONITO_PCICONF_REG_OFFSET;
if (idsel == 0) {
fprintf(stderr, "error in bonito pci config address " TARGET_FMT_plx
",pcimap_cfg=%x\n", addr, s->regs[BONITO_PCIMAP_CFG]);
exit(1);
}
pciaddr = PCI_ADDR(pci_bus_num(phb->bus), devno, funno, regno);
DPRINTF("cfgaddr %x pciaddr %x busno %x devno %d funno %d regno %d\n",
cfgaddr, pciaddr, pci_bus_num(phb->bus), devno, funno, regno);
return pciaddr;
}
| 1threat
|
Architecture in the .NET Core world : <p>There appear to be many benefits of using the .NET Core framework and we are investigating these to see if/when we should migrate our applications.</p>
<p>One of the really appealing philosophies in .NET Core is that of only utilizing the parts of the .NET framework that are required, loading these <em>via</em> Nuget packages.</p>
<p>Were we to migrate, then I'd really like our own framework to mirror the leanness of the .NET Core approach. Currently, it's more allied to the full .NET framework approach where we load fairly "fat" DLLs. I've not seen any specific advice on how best to architect an application addressing .NET Core, so am after advice here.</p>
<p>For simplicity's sake, let's imagine that we have just two applications: App-A and App-B.</p>
<p>Both applications need to access data held in SQL which is accessed by stored procedures. App-A is different to App-B, but they are related, so you can imagine that some stored-procedures are called only by App-A, some only by App-B and some are called by both. </p>
<p>All the code that calls these stored procedures is held in a common DLL called "SQL-DLL". Yes, the DLL exposes interfaces that are specific to App-A and App-B, but the DLL still contain ALL the code and so can be considered "fat" rather than "lean".</p>
<p>For just 2 applications, one could consider splitting this into 3 DLLs: one just containing calls for App-A, one just for calls for App-B and one for all common calls. But, what if you have (say) 10 applications? The permutations become much higher and it soon becomes unclear which calls exist in which DLLs.</p>
<p>Better maybe to split the DLL into smaller functional DLLs - a bit like "micro-services"? One DLL for all the Customer details, one DLL for all the Order details, one DLL for all the....but there again, does "GetCustomerOrders" belong in Customer or Orders? Hmmm.</p>
<p>If anyone has any good advice on keeping code lean for the .NET Core world, then please do let me know.</p>
<p>In addition, we have one Visual Studio solution per application, and each solution has the shared Projects. Some people recommend having the shared libraries as Nuget packages rather than projects, but I think this would make it overall harder to debug and to TDD. Thoughts on this?</p>
<p>And finally, how best to organize this in the the source repository (e.g. TFS). Currently, the shared projects result in relative paths that contain lots of "../../" which works fine in Visual Studio, but can cause problems on the build server when Nuget packages aren't in their expected paths.</p>
<p>I know I've asked a lot here, but any/all recommendations would be most appreciated!</p>
| 0debug
|
Error 'Implicit string cast with potential data loss from 'string' to 'AnsiString' in Delphi XE2' : How can I remove this error?
String1:= inttoStr(instance.CurrentSpeed);
UDPSocket1.Sendln(String1);
| 0debug
|
pyspark error: AttributeError: 'SparkSession' object has no attribute 'parallelize' : <p>I am using pyspark on Jupyter notebook. Here is how Spark setup:</p>
<pre><code>import findspark
findspark.init(spark_home='/home/edamame/spark/spark-2.0.0-bin-spark-2.0.0-bin-hadoop2.6-hive', python_path='python2.7')
import pyspark
from pyspark.sql import *
sc = pyspark.sql.SparkSession.builder.master("yarn-client").config("spark.executor.memory", "2g").config('spark.driver.memory', '1g').config('spark.driver.cores', '4').enableHiveSupport().getOrCreate()
sqlContext = SQLContext(sc)
</code></pre>
<p>Then when I do:</p>
<pre><code>spark_df = sqlContext.createDataFrame(df_in)
</code></pre>
<p>where <code>df_in</code> is a pandas dataframe. I then got the following errors:</p>
<pre><code>---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-9-1db231ce21c9> in <module>()
----> 1 spark_df = sqlContext.createDataFrame(df_in)
/home/edamame/spark/spark-2.0.0-bin-spark-2.0.0-bin-hadoop2.6-hive/python/pyspark/sql/context.pyc in createDataFrame(self, data, schema, samplingRatio)
297 Py4JJavaError: ...
298 """
--> 299 return self.sparkSession.createDataFrame(data, schema, samplingRatio)
300
301 @since(1.3)
/home/edamame/spark/spark-2.0.0-bin-spark-2.0.0-bin-hadoop2.6-hive/python/pyspark/sql/session.pyc in createDataFrame(self, data, schema, samplingRatio)
520 rdd, schema = self._createFromRDD(data.map(prepare), schema, samplingRatio)
521 else:
--> 522 rdd, schema = self._createFromLocal(map(prepare, data), schema)
523 jrdd = self._jvm.SerDeUtil.toJavaArray(rdd._to_java_object_rdd())
524 jdf = self._jsparkSession.applySchemaToPythonRDD(jrdd.rdd(), schema.json())
/home/edamame/spark/spark-2.0.0-bin-spark-2.0.0-bin-hadoop2.6-hive/python/pyspark/sql/session.pyc in _createFromLocal(self, data, schema)
400 # convert python objects to sql data
401 data = [schema.toInternal(row) for row in data]
--> 402 return self._sc.parallelize(data), schema
403
404 @since(2.0)
AttributeError: 'SparkSession' object has no attribute 'parallelize'
</code></pre>
<p>Does anyone know what I did wrong? Thanks!</p>
| 0debug
|
Node.js: Pass data from a callback to the calling function : <p>Please, a simple example of how to pass data from a callback to the calling function in Node.js?</p>
| 0debug
|
static void handle_windowevent(SDL_Event *ev)
{
struct sdl2_console *scon = get_scon_from_window(ev->window.windowID);
if (!scon) {
return;
}
switch (ev->window.event) {
case SDL_WINDOWEVENT_RESIZED:
{
QemuUIInfo info;
memset(&info, 0, sizeof(info));
info.width = ev->window.data1;
info.height = ev->window.data2;
dpy_set_ui_info(scon->dcl.con, &info);
}
sdl2_redraw(scon);
break;
case SDL_WINDOWEVENT_EXPOSED:
sdl2_redraw(scon);
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
case SDL_WINDOWEVENT_ENTER:
if (!gui_grab && (qemu_input_is_absolute() || absolute_enabled)) {
absolute_mouse_grab(scon);
}
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
if (gui_grab && !gui_fullscreen) {
sdl_grab_end(scon);
}
break;
case SDL_WINDOWEVENT_RESTORED:
update_displaychangelistener(&scon->dcl, GUI_REFRESH_INTERVAL_DEFAULT);
break;
case SDL_WINDOWEVENT_MINIMIZED:
update_displaychangelistener(&scon->dcl, 500);
break;
case SDL_WINDOWEVENT_CLOSE:
if (qemu_console_is_graphic(scon->dcl.con)) {
if (!no_quit) {
no_shutdown = 0;
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
}
} else {
SDL_HideWindow(scon->real_window);
scon->hidden = true;
}
break;
case SDL_WINDOWEVENT_SHOWN:
if (scon->hidden) {
SDL_HideWindow(scon->real_window);
}
break;
case SDL_WINDOWEVENT_HIDDEN:
if (!scon->hidden) {
SDL_ShowWindow(scon->real_window);
}
break;
}
}
| 1threat
|
C programming -How to count number of repetition of letter in a word : I am trying to write a program where its supposed to count the occurrence of each characters using getchar()
For example if the input is xxxyyyzzzz ; the output should be 334 (x is repeated 3 times, y 3 and z 4times).
If the input is xxyxx the output should be 212
Here's what i have tried so far
double nc ;
for (nc=0 ; getchar()!=EOF;++nc);
printf ("%.0f\n",nc);
return 0;
Input aaabbbccc
Output 10
Expected Output = 333
Unfortunately , this shows the total number of characters including enter but not the repetition . I would really appreciate any suggestions for me to get this program going . Thank you
| 0debug
|
int avformat_network_init(void)
{
#if CONFIG_NETWORK
int ret;
ff_network_inited_globally = 1;
if ((ret = ff_network_init()) < 0)
return ret;
ff_tls_init();
#endif
return 0;
}
| 1threat
|
How to fix 'Dict object has no attrubute key' : <p>I got this error, while i have attribute key there.</p>
<pre><code>Traceback (most recent call last):
File "C:/Users/Acer/AppData/Local/Programs/Python/Python37- 32/randomQuizGenerator.py", line 33, in <module>
states = list(capitals.key())
AttributeError: 'dict' object has no attribute 'key'
</code></pre>
<p>I am new in Python btw. I follow along all of the tutorial.
and while my dict is here:</p>
<pre><code>capitals = {'Alabama': 'Montgemory', 'Alaska': 'Juneau', 'Arizona': 'Phoenix', 'Arkansas': 'Little Rock', 'California': 'Sacramento', 'Colorado': 'Denver',
'Connecticut': 'Hartford', 'Delaware': 'Dover', 'Florida': 'Tallahassee',
'Georgia': 'Atlanta', 'Hawaii': 'Honolulu', 'Idaho': 'Boise', 'Illinois':
'Springfield', 'Indiana': 'Indianapolis', 'Iowa': 'Des Moines', 'Kansas':
'Topeka', 'Kentucky': 'Frankfort', 'Louisiana': 'Baton Rouge', 'Maine':
'Augusta', 'Maryland': 'Annapolis', 'Massachusetts': 'Boston', 'Michigan':
'Lansing', 'Minnesota': 'Saint Paul', 'Mississippi': 'Jackson', 'Missouri':
'Jefferson City', 'Montana': 'Helena', 'Nebraska': 'Lincoln', 'Nevada':
'Carson City', 'New Hampshire': 'Concord', 'New Jersey': 'Trenton', 'New Mexico': 'Santa Fe', 'New York': 'Albany', 'North Carolina': 'Raleigh',
'North Dakota': 'Bismarck', 'Ohio': 'Columbus', 'Oklahoma': 'Oklahoma City',
'Oregon': 'Salem', 'Pennsylvania': 'Harrisburg', 'Rhode Island': 'Providence',
'South Carolina': 'Columbia', 'South Dakota': 'Pierre', 'Tennessee':
'Nashville', 'Texas': 'Austin', 'Utah': 'Salt Lake City', 'Vermont':
'Montpelier', 'Virginia': 'Richmond', 'Washington': 'Olympia', 'West Virginia': 'Charleston', 'Wisconsin': 'Madison', 'Wyoming': 'Cheyenne'}
</code></pre>
<p>I have the key attribute in my dictionary, i don't know which part is wrong actually.</p>
<p>I expected the result is like this:</p>
<pre><code> State Capitals Quiz (Form 1)
1. What is the capital of West Virginia?
A. Hartford
B. Santa Fe
C. Harrisburg
D. Charleston
2. What is the capital of Colorado?
A. Raleigh
B. Harrisburg
C. Denver
D. Lincoln
</code></pre>
| 0debug
|
Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in /web/htdocs/www.bp-electronics.com/home/bpgest2/sheets/ddt.php on line 40 : <p>Good morning,
I have watched many times the code below and I could not understand where is the error. previously the error was on line 38 and was able to correct it, but now I just can not.
Please help me.</p>
<p>thanks in advance</p>
<pre><code><?php
if(!$getQ[1]){
if(@$_GET['undo']){mysql_query("UPDATE ddt SET ddtundo=1 WHERE id='".$_GET['undo']."'");}
?>
<br><br>
<table border="0" cellspacing="1" cellpadding="4" width="99%" align="center">
<tr>
<td align="center" width="22"></td>
<td align="left" class="txt_lit_grey" width="180"><b>Data</b></td>
<td align="left" class="txt_lit_grey"><b>Cliente</b></td>
<td align="left" class="txt_lit_grey"><b>Decoder</b></td>
<td align="left" class="txt_lit_grey" width="90"><b>N. articoli</b></td>
<td align="center" width="22"></td>
<td align="center" width="22"></td>
<td align="center" width="22"></td>
<td align="center" width="22"></td>
</tr>
<?php
$row=0;
$qu=mysql_query("SELECT * FROM users");
while($ru=mysql_fetch_assoc($qu)){$users[$ru['id']]=$ru['fullname'];}
$q=mysql_query("SELECT * FROM ddt ORDER BY data DESC");
while($r=mysql_fetch_assoc($q)){
$tot=count(explode("|",$r['ware']));
$items=explode("|",$r['ware']);
for($i=0;$i<count($items);$i++){
if($i%2){$fill=1;}else{$fill=0;}
$value=explode("#",$items[$i]);
$qc=mysql_query("SELECT * FROM catalog WHERE id='".$value[0]."'");
$rc=mysql_fetch_assoc($qc);
}
if($row%2){$bgcolor="#ffffff";}else{$bgcolor="#eeeeee";}
echo "<tr>n";
if($r['ddtundo']){echo "<td bgcolor="#dddddd" height="5" align="center" class="txt_lit_white radius"> </td>n";}else{echo "<td bgcolor="#dddddd" height="5" align="center" class="txt_lit_white radius"> </td>n";}
echo "<td bgcolor="$bgcolor" height="5" align="left" class="txt_lit_black">".date("d/m/Y H:i.s",strtotime($r['data']))."</td>n";
echo "<td bgcolor="$bgcolor" height="5" align="left" class="txt_lit_black">".$r['operator']."</td>n";
echo "<td bgcolor="$bgcolor" height="5" align="left" class="txt_lit_black">".$rc['short_description']."</td>n";
echo "<td bgcolor="$bgcolor" height="5" align="left" class="txt_lit_black">".$tot."</td>n";
echo "<td bgcolor="$bgcolor" align="center"><a class="cb_iframe" href="sheets/ddt/pdf_ddt.php?id=".$r['id']."" title="Visualizza"><img src="img/icons/view.png"></a></td>n";
echo "<td bgcolor="$bgcolor" align="center"><a class="cb_iframe" href="sheets/ddt/modify.php?id=".$r['id']."" title="Modifica"><img src="img/icons/modify.png"></a></td>n";
echo "<td bgcolor="$bgcolor" align="center"><a class="cb_iframe" href="sheets/ddt/delete.php?id=".$r['id']."" title="Elimina"><img src="img/icons/download.png"></a></td>n";
echo "</tr>n";
$row++;
}
?>
</table>
<table border="0" cellspacing="4" cellpadding="4" width="99%">
<tr>
<td valign="top" align="right">
<a href"sheets/ddt/new_ddt.php"><input type="button" class="button_blu button_big" value="<?php if($_SESSION['DDT']['DATA']){echo "Apri DDT in sospeso";}else{echo "Nuovo DDT";}?>">
</a>
</td>
</tr>
</table>
<?php
}else{@include 'sheets/ddt/new_ddt.php';}
?>
</code></pre>
| 0debug
|
How to solved "Observable.share is not a function" Angular 2 :
I use cache structure in ionic 2. I define an observable array. I record the data that is returned from the server here. But every time this shape gives me a mistake. How do I solve it?
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
marketArray : Observable<any>; /* GLOBAL */ this.http.get(this.base_url,header).map(res=>res.json()).subscribe(data=>{
loader.dismissAll();
this.marketArray = this.cache.loadFromObservable(this.base_url, data["Table"]);
}, (error)=>{
loader.dismissAll();
this.marketler();
});
<!-- end snippet -->
| 0debug
|
Complete tmux reset : <p>I was wondering if it is possible to completely reset tmux (the UI mainly) ?
I have tried deleting my <code>~/.tmux.conf</code> and reinstalling tmux it but I always ended up with the same status bar I had defined. </p>
| 0debug
|
static void gem_init(NICInfo *nd, uint32_t base, qemu_irq irq)
{
DeviceState *dev;
SysBusDevice *s;
qemu_check_nic_model(nd, "cadence_gem");
dev = qdev_create(NULL, "cadence_gem");
qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);
s = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(s, 0, base);
sysbus_connect_irq(s, 0, irq);
}
| 1threat
|
Comparing Text Fields Value : <p>using the Internet, Android Studio, and your current knowledge of Android app development, create an Android app project that has two (2) text fields and one (1) button. The button will compare the input from the text fields and display a response (SAME if values are the same and NOT THE SAME if they are not) if it is clicked. You may need to create a new activity for this</p>
| 0debug
|
static uint64_t omap_eac_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
struct omap_eac_s *s = (struct omap_eac_s *) opaque;
uint32_t ret;
if (size != 2) {
return omap_badwidth_read16(opaque, addr);
}
switch (addr) {
case 0x000:
return s->config[0];
case 0x004:
return s->config[1];
case 0x008:
return s->config[2];
case 0x00c:
return s->config[3];
case 0x010:
return s->control | ((s->codec.rxavail + s->codec.rxlen > 0) << 7) |
((s->codec.txlen < s->codec.txavail) << 5);
case 0x014:
return s->address;
case 0x018:
return s->data & 0xff;
case 0x01c:
return s->data >> 8;
case 0x020:
return s->vtol;
case 0x024:
return s->vtsl | (3 << 5);
case 0x040:
return s->modem.control;
case 0x044:
return s->modem.config;
case 0x060:
return s->bt.control;
case 0x064:
return s->bt.config;
case 0x080:
return s->mixer;
case 0x084:
return s->gain[0];
case 0x088:
return s->gain[1];
case 0x08c:
return s->gain[2];
case 0x090:
return s->gain[3];
case 0x094:
return s->att;
case 0x098:
return s->max[0];
case 0x09c:
return s->max[1];
case 0x0a0:
return s->max[2];
case 0x0a4:
return s->max[3];
case 0x0a8:
return s->max[4];
case 0x0ac:
return s->max[5];
case 0x0b0:
return s->max[6];
case 0x0b4:
return 0x0000;
case 0x0b8:
if (likely(s->codec.rxlen > 1)) {
ret = s->codec.rxbuf[s->codec.rxoff ++];
s->codec.rxlen --;
s->codec.rxoff &= EAC_BUF_LEN - 1;
return ret;
} else if (s->codec.rxlen) {
ret = s->codec.rxbuf[s->codec.rxoff ++];
s->codec.rxlen --;
s->codec.rxoff &= EAC_BUF_LEN - 1;
if (s->codec.rxavail)
omap_eac_in_refill(s);
omap_eac_in_dmarequest_update(s);
return ret;
}
return 0x0000;
case 0x0bc:
return s->codec.config[0];
case 0x0c0:
return s->codec.config[1] | ((s->codec.config[1] & 2) << 14);
case 0x0c4:
return s->codec.config[2];
case 0x0c8:
return s->codec.config[3];
case 0x0cc:
case 0x0d0:
case 0x0d8:
case 0x0e4:
case 0x0ec:
return 0x0000;
case 0x100:
return 0x0010;
case 0x104:
return s->sysconfig;
case 0x108:
return 1 | 0xe;
}
OMAP_BAD_REG(addr);
return 0;
}
| 1threat
|
When does a C# Task actually start? : <p>When does a Task actually start?</p>
<pre><code>public void DoSomething() {
Task myTask = DoSomethingAsync();
Task.WaitAll(new[] { myTask }, 2000);
}
public async Task DoSomethingAsync() {
await SomethingElse();
}
</code></pre>
<p>Does it start immediately when initializing it in <code>Task myTask = DoSomethingAsync();</code> or does it start when you say to wait for it in <code>Task.WaitAll(new[] { myTask }, 2000);</code> ?</p>
| 0debug
|
New to SQL Scripting : I have spent most of my career learning the data platform with sql however I want to get more involved with querying. I am making my own scenarios and attempting to pull data out of tables I have created but I am hitting s wall. Apologies this is probably simplistic query but I am hoping you can enlighten me as to what I am doing incorrectly and to provide assistance. The Premise is I have a list of PCs that I want to rebuild but only based on if all apps that are installed on them are windows 10 compatible.
I have a few tables.
Tbl_Windows_7_PCs
Fields are
MachineName
IPAddress
AssignedUser
Application
Now this table shows multiple rows it has no primary key. An example is as follows
Pc001 10.0.0.20 Joe Bloggs Ms Word 2016
Pc001 10.0.0.20 Joe Bloggs Ms Excel 2016
Pc001 10.0.0.20 Joe Bloggs Ms Access 2016
Pc002 10.0.0.34 Jane Smith Ms Excel 2016
Pc002 10.0.0.34 Jane Smith Sage
Pc002 10.0.0.34 Jane Smith Adobe Acrobat
I have another table called Windows Compatible Aplications
Once again no primary key
Tbl_Win10_Compatible_Apps
Fields are but one
Application
Values are
MS Excel 2016
Sage
Adobe Acrobat
So I want to produce a query that selects only the machine name and the assigneduser from tbl_Windows_7_PCs Where all applications that are installed are present in Tbl_Win10_Compatible_Apps.
The kicker is I don’t want to pull back all of the rows I just want to show the machine and user (singular) if that makes sense.
As I am learning would appreciate if anyone has the solution to explain how they arrived at the solution.
| 0debug
|
Stuck on a challenge Python SImple : Write a function named operate that takes as parameters 2 integers named a, b and a function named func which that takes 2 integers as parameters. Also write the functions add, sub, mul, and div that take 2 integer parameters and perform the operation corresponding to their name and print the result. Calling operate(a, b, func) should result in a call to func(a, b).
| 0debug
|
static void mv88w8618_pit_write(void *opaque, target_phys_addr_t offset,
uint32_t value)
{
mv88w8618_pit_state *s = opaque;
mv88w8618_timer_state *t;
int i;
switch (offset) {
case MP_PIT_TIMER1_LENGTH ... MP_PIT_TIMER4_LENGTH:
t = &s->timer[offset >> 2];
t->limit = value;
ptimer_set_limit(t->ptimer, t->limit, 1);
break;
case MP_PIT_CONTROL:
for (i = 0; i < 4; i++) {
if (value & 0xf) {
t = &s->timer[i];
ptimer_set_limit(t->ptimer, t->limit, 0);
ptimer_set_freq(t->ptimer, t->freq);
ptimer_run(t->ptimer, 0);
}
value >>= 4;
}
break;
case MP_BOARD_RESET:
if (value == MP_BOARD_RESET_MAGIC) {
qemu_system_reset_request();
}
break;
}
}
| 1threat
|
static int init_prec(Jpeg2000Band *band,
Jpeg2000ResLevel *reslevel,
Jpeg2000Component *comp,
int precno, int bandno, int reslevelno,
int log2_band_prec_width,
int log2_band_prec_height)
{
Jpeg2000Prec *prec = band->prec + precno;
int nb_codeblocks, cblkno;
prec->decoded_layers = 0;
prec->coord[0][0] = ((band->coord[0][0] >> log2_band_prec_width) + precno % reslevel->num_precincts_x) *
(1 << log2_band_prec_width);
prec->coord[1][0] = ((band->coord[1][0] >> log2_band_prec_height) + precno / reslevel->num_precincts_x) *
(1 << log2_band_prec_height);
prec->coord[0][1] = prec->coord[0][0] +
(1 << log2_band_prec_width);
prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]);
prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]);
prec->coord[1][1] = prec->coord[1][0] +
(1 << log2_band_prec_height);
prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]);
prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]);
prec->nb_codeblocks_width =
ff_jpeg2000_ceildivpow2(prec->coord[0][1],
band->log2_cblk_width)
- (prec->coord[0][0] >> band->log2_cblk_width);
prec->nb_codeblocks_height =
ff_jpeg2000_ceildivpow2(prec->coord[1][1],
band->log2_cblk_height)
- (prec->coord[1][0] >> band->log2_cblk_height);
prec->cblkincl =
ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->cblkincl)
return AVERROR(ENOMEM);
prec->zerobits =
ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->zerobits)
return AVERROR(ENOMEM);
if (prec->nb_codeblocks_width * (uint64_t)prec->nb_codeblocks_height > INT_MAX) {
prec->cblk = NULL;
return AVERROR(ENOMEM);
}
nb_codeblocks = prec->nb_codeblocks_width * prec->nb_codeblocks_height;
prec->cblk = av_mallocz_array(nb_codeblocks, sizeof(*prec->cblk));
if (!prec->cblk)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < nb_codeblocks; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
int Cx0, Cy0;
Cx0 = ((prec->coord[0][0]) >> band->log2_cblk_width) << band->log2_cblk_width;
Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width);
cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]);
Cy0 = ((prec->coord[1][0]) >> band->log2_cblk_height) << band->log2_cblk_height;
Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height);
cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]);
cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width),
prec->coord[0][1]);
cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height),
prec->coord[1][1]);
if ((bandno + !!reslevelno) & 1) {
cblk->coord[0][0] += comp->reslevel[reslevelno-1].coord[0][1] -
comp->reslevel[reslevelno-1].coord[0][0];
cblk->coord[0][1] += comp->reslevel[reslevelno-1].coord[0][1] -
comp->reslevel[reslevelno-1].coord[0][0];
}
if ((bandno + !!reslevelno) & 2) {
cblk->coord[1][0] += comp->reslevel[reslevelno-1].coord[1][1] -
comp->reslevel[reslevelno-1].coord[1][0];
cblk->coord[1][1] += comp->reslevel[reslevelno-1].coord[1][1] -
comp->reslevel[reslevelno-1].coord[1][0];
}
cblk->zero = 0;
cblk->lblock = 3;
cblk->length = 0;
memset(cblk->lengthinc, 0, sizeof(cblk->lengthinc));
cblk->npasses = 0;
}
return 0;
}
| 1threat
|
static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
int j, entries, pseudo_stream_id;
get_byte(pb);
get_be24(pb);
entries = get_be32(pb);
for(pseudo_stream_id=0; pseudo_stream_id<entries; pseudo_stream_id++) {
enum CodecID id;
int dref_id;
MOV_atom_t a = { 0, 0, 0 };
offset_t start_pos = url_ftell(pb);
int size = get_be32(pb);
uint32_t format = get_le32(pb);
get_be32(pb);
get_be16(pb);
dref_id = get_be16(pb);
if (st->codec->codec_tag &&
st->codec->codec_tag != format &&
(c->fc->video_codec_id ? codec_get_id(codec_movvideo_tags, format) != c->fc->video_codec_id
: st->codec->codec_tag != MKTAG('j','p','e','g'))
){
av_log(c->fc, AV_LOG_WARNING, "multiple fourcc not supported\n");
url_fskip(pb, size - (url_ftell(pb) - start_pos));
continue;
}
sc->pseudo_stream_id = st->codec->codec_tag ? -1 : pseudo_stream_id;
sc->dref_id= dref_id;
st->codec->codec_tag = format;
id = codec_get_id(codec_movaudio_tags, format);
if (id<=0 && (format&0xFFFF) == 'm'+('s'<<8))
id = codec_get_id(codec_wav_tags, bswap_32(format)&0xFFFF);
if (st->codec->codec_type != CODEC_TYPE_VIDEO && id > 0) {
st->codec->codec_type = CODEC_TYPE_AUDIO;
} else if (st->codec->codec_type != CODEC_TYPE_AUDIO &&
format && format != MKTAG('m','p','4','s')) {
id = codec_get_id(codec_movvideo_tags, format);
if (id <= 0)
id = codec_get_id(codec_bmp_tags, format);
if (id > 0)
st->codec->codec_type = CODEC_TYPE_VIDEO;
else if(st->codec->codec_type == CODEC_TYPE_DATA){
id = codec_get_id(ff_codec_movsubtitle_tags, format);
if(id > 0)
st->codec->codec_type = CODEC_TYPE_SUBTITLE;
}
}
dprintf(c->fc, "size=%d 4CC= %c%c%c%c codec_type=%d\n", size,
(format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
(format >> 24) & 0xff, st->codec->codec_type);
if(st->codec->codec_type==CODEC_TYPE_VIDEO) {
uint8_t codec_name[32];
unsigned int color_depth;
int color_greyscale;
st->codec->codec_id = id;
get_be16(pb);
get_be16(pb);
get_be32(pb);
get_be32(pb);
get_be32(pb);
st->codec->width = get_be16(pb);
st->codec->height = get_be16(pb);
get_be32(pb);
get_be32(pb);
get_be32(pb);
get_be16(pb);
get_buffer(pb, codec_name, 32);
if (codec_name[0] <= 31) {
memcpy(st->codec->codec_name, &codec_name[1],codec_name[0]);
st->codec->codec_name[codec_name[0]] = 0;
}
st->codec->bits_per_coded_sample = get_be16(pb);
st->codec->color_table_id = get_be16(pb);
dprintf(c->fc, "depth %d, ctab id %d\n",
st->codec->bits_per_coded_sample, st->codec->color_table_id);
color_depth = st->codec->bits_per_coded_sample & 0x1F;
color_greyscale = st->codec->bits_per_coded_sample & 0x20;
if ((color_depth == 2) || (color_depth == 4) ||
(color_depth == 8)) {
unsigned int color_start, color_count, color_end;
unsigned char r, g, b;
if (color_greyscale) {
int color_index, color_dec;
st->codec->bits_per_coded_sample = color_depth;
color_count = 1 << color_depth;
color_index = 255;
color_dec = 256 / (color_count - 1);
for (j = 0; j < color_count; j++) {
r = g = b = color_index;
c->palette_control.palette[j] =
(r << 16) | (g << 8) | (b);
color_index -= color_dec;
if (color_index < 0)
color_index = 0;
}
} else if (st->codec->color_table_id) {
const uint8_t *color_table;
color_count = 1 << color_depth;
if (color_depth == 2)
color_table = ff_qt_default_palette_4;
else if (color_depth == 4)
color_table = ff_qt_default_palette_16;
else
color_table = ff_qt_default_palette_256;
for (j = 0; j < color_count; j++) {
r = color_table[j * 4 + 0];
g = color_table[j * 4 + 1];
b = color_table[j * 4 + 2];
c->palette_control.palette[j] =
(r << 16) | (g << 8) | (b);
}
} else {
color_start = get_be32(pb);
color_count = get_be16(pb);
color_end = get_be16(pb);
if ((color_start <= 255) &&
(color_end <= 255)) {
for (j = color_start; j <= color_end; j++) {
get_byte(pb);
get_byte(pb);
r = get_byte(pb);
get_byte(pb);
g = get_byte(pb);
get_byte(pb);
b = get_byte(pb);
get_byte(pb);
c->palette_control.palette[j] =
(r << 16) | (g << 8) | (b);
}
}
}
st->codec->palctrl = &c->palette_control;
st->codec->palctrl->palette_changed = 1;
} else
st->codec->palctrl = NULL;
} else if(st->codec->codec_type==CODEC_TYPE_AUDIO) {
int bits_per_sample, flags;
uint16_t version = get_be16(pb);
st->codec->codec_id = id;
get_be16(pb);
get_be32(pb);
st->codec->channels = get_be16(pb);
dprintf(c->fc, "audio channels %d\n", st->codec->channels);
st->codec->bits_per_coded_sample = get_be16(pb);
sc->audio_cid = get_be16(pb);
get_be16(pb);
st->codec->sample_rate = ((get_be32(pb) >> 16));
dprintf(c->fc, "version =%d, isom =%d\n",version,c->isom);
if(!c->isom) {
if(version==1) {
sc->samples_per_frame = get_be32(pb);
get_be32(pb);
sc->bytes_per_frame = get_be32(pb);
get_be32(pb);
} else if(version==2) {
get_be32(pb);
st->codec->sample_rate = av_int2dbl(get_be64(pb));
st->codec->channels = get_be32(pb);
get_be32(pb);
st->codec->bits_per_coded_sample = get_be32(pb);
flags = get_be32(pb);
sc->bytes_per_frame = get_be32(pb);
sc->samples_per_frame = get_be32(pb);
if (format == MKTAG('l','p','c','m'))
st->codec->codec_id = mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, flags);
}
}
switch (st->codec->codec_id) {
case CODEC_ID_PCM_S8:
case CODEC_ID_PCM_U8:
if (st->codec->bits_per_coded_sample == 16)
st->codec->codec_id = CODEC_ID_PCM_S16BE;
break;
case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
if (st->codec->bits_per_coded_sample == 8)
st->codec->codec_id = CODEC_ID_PCM_S8;
else if (st->codec->bits_per_coded_sample == 24)
st->codec->codec_id =
st->codec->codec_id == CODEC_ID_PCM_S16BE ?
CODEC_ID_PCM_S24BE : CODEC_ID_PCM_S24LE;
break;
case CODEC_ID_MACE3:
sc->samples_per_frame = 6;
sc->bytes_per_frame = 2*st->codec->channels;
break;
case CODEC_ID_MACE6:
sc->samples_per_frame = 6;
sc->bytes_per_frame = 1*st->codec->channels;
break;
case CODEC_ID_ADPCM_IMA_QT:
sc->samples_per_frame = 64;
sc->bytes_per_frame = 34*st->codec->channels;
break;
case 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;
}
} else if(st->codec->codec_type==CODEC_TYPE_SUBTITLE){
st->codec->codec_id= id;
} else {
url_fskip(pb, size - (url_ftell(pb) - start_pos));
}
a.size = size - (url_ftell(pb) - start_pos);
if (a.size > 8) {
if (mov_read_default(c, pb, a) < 0)
return -1;
} else if (a.size > 0)
url_fskip(pb, a.size);
}
if(st->codec->codec_type==CODEC_TYPE_AUDIO && st->codec->sample_rate==0 && sc->time_scale>1)
st->codec->sample_rate= sc->time_scale;
switch (st->codec->codec_id) {
#ifdef CONFIG_DV_DEMUXER
case CODEC_ID_DVAUDIO:
c->dv_fctx = av_alloc_format_context();
c->dv_demux = dv_init_demux(c->dv_fctx);
if (!c->dv_demux) {
av_log(c->fc, AV_LOG_ERROR, "dv demux context init error\n");
return -1;
}
sc->dv_audio_container = 1;
st->codec->codec_id = CODEC_ID_PCM_S16LE;
break;
#endif
case CODEC_ID_AMR_WB:
st->codec->sample_rate= 16000;
st->codec->channels= 1;
break;
case CODEC_ID_QCELP:
case CODEC_ID_AMR_NB:
st->codec->frame_size= sc->samples_per_frame;
st->codec->sample_rate= 8000;
st->codec->channels= 1;
break;
case CODEC_ID_MP2:
case CODEC_ID_MP3:
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->need_parsing = AVSTREAM_PARSE_FULL;
break;
case CODEC_ID_GSM:
case CODEC_ID_ADPCM_MS:
case CODEC_ID_ADPCM_IMA_WAV:
st->codec->block_align = sc->bytes_per_frame;
break;
case CODEC_ID_ALAC:
if (st->codec->extradata_size == 36)
st->codec->frame_size = AV_RB32((st->codec->extradata+12));
break;
default:
break;
}
return 0;
}
| 1threat
|
static int disas_thumb2_insn(DisasContext *s, uint32_t insn)
{
uint32_t imm, shift, offset;
uint32_t rd, rn, rm, rs;
TCGv_i32 tmp;
TCGv_i32 tmp2;
TCGv_i32 tmp3;
TCGv_i32 addr;
TCGv_i64 tmp64;
int op;
int shiftop;
int conds;
int logic_cc;
if ((insn & 0xf800e800) != 0xf000e800) {
ARCH(6T2);
}
rn = (insn >> 16) & 0xf;
rs = (insn >> 12) & 0xf;
rd = (insn >> 8) & 0xf;
rm = insn & 0xf;
switch ((insn >> 25) & 0xf) {
case 0: case 1: case 2: case 3:
abort();
case 4:
if (insn & (1 << 22)) {
if (insn == 0xe97fe97f && arm_dc_feature(s, ARM_FEATURE_M) &&
arm_dc_feature(s, ARM_FEATURE_V8)) {
if (s->v8m_secure) {
s->condexec_cond = 0;
s->condexec_mask = 0;
}
} else if (insn & 0x01200000) {
if (rn == 15) {
if (insn & (1 << 21)) {
goto illegal_op;
}
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, s->pc & ~3);
} else {
addr = load_reg(s, rn);
}
offset = (insn & 0xff) * 4;
if ((insn & (1 << 23)) == 0)
offset = -offset;
if (insn & (1 << 24)) {
tcg_gen_addi_i32(addr, addr, offset);
offset = 0;
}
if (insn & (1 << 20)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(s, tmp, addr, get_mem_index(s));
store_reg(s, rs, tmp);
tcg_gen_addi_i32(addr, addr, 4);
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(s, tmp, addr, get_mem_index(s));
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rs);
gen_aa32_st32(s, tmp, addr, get_mem_index(s));
tcg_temp_free_i32(tmp);
tcg_gen_addi_i32(addr, addr, 4);
tmp = load_reg(s, rd);
gen_aa32_st32(s, tmp, addr, get_mem_index(s));
tcg_temp_free_i32(tmp);
}
if (insn & (1 << 21)) {
tcg_gen_addi_i32(addr, addr, offset - 4);
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
} else if ((insn & (1 << 23)) == 0) {
if (rs == 15) {
goto illegal_op;
}
addr = tcg_temp_local_new_i32();
load_reg_var(s, addr, rn);
tcg_gen_addi_i32(addr, addr, (insn & 0xff) << 2);
if (insn & (1 << 20)) {
gen_load_exclusive(s, rs, 15, addr, 2);
} else {
gen_store_exclusive(s, rd, rs, 15, addr, 2);
}
tcg_temp_free_i32(addr);
} else if ((insn & (7 << 5)) == 0) {
if (rn == 15) {
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, s->pc);
} else {
addr = load_reg(s, rn);
}
tmp = load_reg(s, rm);
tcg_gen_add_i32(addr, addr, tmp);
if (insn & (1 << 4)) {
tcg_gen_add_i32(addr, addr, tmp);
tcg_temp_free_i32(tmp);
tmp = tcg_temp_new_i32();
gen_aa32_ld16u(s, tmp, addr, get_mem_index(s));
} else {
tcg_temp_free_i32(tmp);
tmp = tcg_temp_new_i32();
gen_aa32_ld8u(s, tmp, addr, get_mem_index(s));
}
tcg_temp_free_i32(addr);
tcg_gen_shli_i32(tmp, tmp, 1);
tcg_gen_addi_i32(tmp, tmp, s->pc);
store_reg(s, 15, tmp);
} else {
int op2 = (insn >> 6) & 0x3;
op = (insn >> 4) & 0x3;
switch (op2) {
case 0:
goto illegal_op;
case 1:
if (op == 2) {
goto illegal_op;
}
ARCH(7);
break;
case 2:
if (op == 3) {
goto illegal_op;
}
case 3:
ARCH(8);
break;
}
addr = tcg_temp_local_new_i32();
load_reg_var(s, addr, rn);
if (!(op2 & 1)) {
if (insn & (1 << 20)) {
tmp = tcg_temp_new_i32();
switch (op) {
case 0:
gen_aa32_ld8u_iss(s, tmp, addr, get_mem_index(s),
rs | ISSIsAcqRel);
break;
case 1:
gen_aa32_ld16u_iss(s, tmp, addr, get_mem_index(s),
rs | ISSIsAcqRel);
break;
case 2:
gen_aa32_ld32u_iss(s, tmp, addr, get_mem_index(s),
rs | ISSIsAcqRel);
break;
default:
abort();
}
store_reg(s, rs, tmp);
} else {
tmp = load_reg(s, rs);
switch (op) {
case 0:
gen_aa32_st8_iss(s, tmp, addr, get_mem_index(s),
rs | ISSIsAcqRel);
break;
case 1:
gen_aa32_st16_iss(s, tmp, addr, get_mem_index(s),
rs | ISSIsAcqRel);
break;
case 2:
gen_aa32_st32_iss(s, tmp, addr, get_mem_index(s),
rs | ISSIsAcqRel);
break;
default:
abort();
}
tcg_temp_free_i32(tmp);
}
} else if (insn & (1 << 20)) {
gen_load_exclusive(s, rs, rd, addr, op);
} else {
gen_store_exclusive(s, rm, rs, rd, addr, op);
}
tcg_temp_free_i32(addr);
}
} else {
if (((insn >> 23) & 1) == ((insn >> 24) & 1)) {
if (IS_USER(s) || arm_dc_feature(s, ARM_FEATURE_M)) {
goto illegal_op;
}
if (insn & (1 << 20)) {
addr = load_reg(s, rn);
if ((insn & (1 << 24)) == 0)
tcg_gen_addi_i32(addr, addr, -8);
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(s, tmp, addr, get_mem_index(s));
tcg_gen_addi_i32(addr, addr, 4);
tmp2 = tcg_temp_new_i32();
gen_aa32_ld32u(s, tmp2, addr, get_mem_index(s));
if (insn & (1 << 21)) {
if (insn & (1 << 24)) {
tcg_gen_addi_i32(addr, addr, 4);
} else {
tcg_gen_addi_i32(addr, addr, -4);
}
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
gen_rfe(s, tmp, tmp2);
} else {
gen_srs(s, (insn & 0x1f), (insn & (1 << 24)) ? 1 : 2,
insn & (1 << 21));
}
} else {
int i, loaded_base = 0;
TCGv_i32 loaded_var;
addr = load_reg(s, rn);
offset = 0;
for (i = 0; i < 16; i++) {
if (insn & (1 << i))
offset += 4;
}
if (insn & (1 << 24)) {
tcg_gen_addi_i32(addr, addr, -offset);
}
TCGV_UNUSED_I32(loaded_var);
for (i = 0; i < 16; i++) {
if ((insn & (1 << i)) == 0)
continue;
if (insn & (1 << 20)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(s, tmp, addr, get_mem_index(s));
if (i == 15) {
gen_bx_excret(s, tmp);
} else if (i == rn) {
loaded_var = tmp;
loaded_base = 1;
} else {
store_reg(s, i, tmp);
}
} else {
tmp = load_reg(s, i);
gen_aa32_st32(s, tmp, addr, get_mem_index(s));
tcg_temp_free_i32(tmp);
}
tcg_gen_addi_i32(addr, addr, 4);
}
if (loaded_base) {
store_reg(s, rn, loaded_var);
}
if (insn & (1 << 21)) {
if (insn & (1 << 24)) {
tcg_gen_addi_i32(addr, addr, -offset);
}
if (insn & (1 << rn))
goto illegal_op;
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
}
}
break;
case 5:
op = (insn >> 21) & 0xf;
if (op == 6) {
if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) {
goto illegal_op;
}
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
shift = ((insn >> 10) & 0x1c) | ((insn >> 6) & 0x3);
if (insn & (1 << 5)) {
if (shift == 0)
shift = 31;
tcg_gen_sari_i32(tmp2, tmp2, shift);
tcg_gen_andi_i32(tmp, tmp, 0xffff0000);
tcg_gen_ext16u_i32(tmp2, tmp2);
} else {
if (shift)
tcg_gen_shli_i32(tmp2, tmp2, shift);
tcg_gen_ext16u_i32(tmp, tmp);
tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000);
}
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else {
if (rn == 15) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else {
tmp = load_reg(s, rn);
}
tmp2 = load_reg(s, rm);
shiftop = (insn >> 4) & 3;
shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c);
conds = (insn & (1 << 20)) != 0;
logic_cc = (conds && thumb2_logic_op(op));
gen_arm_shift_im(tmp2, shiftop, shift, logic_cc);
if (gen_thumb2_data_op(s, op, conds, 0, tmp, tmp2))
goto illegal_op;
tcg_temp_free_i32(tmp2);
if (rd != 15) {
store_reg(s, rd, tmp);
} else {
tcg_temp_free_i32(tmp);
}
}
break;
case 13:
op = ((insn >> 22) & 6) | ((insn >> 7) & 1);
if (op < 4 && (insn & 0xf000) != 0xf000)
goto illegal_op;
switch (op) {
case 0:
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
if ((insn & 0x70) != 0)
goto illegal_op;
op = (insn >> 21) & 3;
logic_cc = (insn & (1 << 20)) != 0;
gen_arm_shift_reg(tmp, op, tmp2, logic_cc);
if (logic_cc)
gen_logic_CC(tmp);
store_reg(s, rd, tmp);
break;
case 1:
op = (insn >> 20) & 7;
switch (op) {
case 0:
case 1:
case 4:
case 5:
break;
case 2:
case 3:
if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) {
goto illegal_op;
}
break;
default:
goto illegal_op;
}
if (rn != 15) {
if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) {
goto illegal_op;
}
}
tmp = load_reg(s, rm);
shift = (insn >> 4) & 3;
if (shift != 0)
tcg_gen_rotri_i32(tmp, tmp, shift * 8);
op = (insn >> 20) & 7;
switch (op) {
case 0: gen_sxth(tmp); break;
case 1: gen_uxth(tmp); break;
case 2: gen_sxtb16(tmp); break;
case 3: gen_uxtb16(tmp); break;
case 4: gen_sxtb(tmp); break;
case 5: gen_uxtb(tmp); break;
default:
g_assert_not_reached();
}
if (rn != 15) {
tmp2 = load_reg(s, rn);
if ((op >> 1) == 1) {
gen_add16(tmp, tmp2);
} else {
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
}
store_reg(s, rd, tmp);
break;
case 2:
if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) {
goto illegal_op;
}
op = (insn >> 20) & 7;
shift = (insn >> 4) & 7;
if ((op & 3) == 3 || (shift & 3) == 3)
goto illegal_op;
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
gen_thumb2_parallel_addsub(op, shift, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 3:
op = ((insn >> 17) & 0x38) | ((insn >> 4) & 7);
if (op < 4) {
if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) {
goto illegal_op;
}
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
if (op & 1)
gen_helper_double_saturate(tmp, cpu_env, tmp);
if (op & 2)
gen_helper_sub_saturate(tmp, cpu_env, tmp2, tmp);
else
gen_helper_add_saturate(tmp, cpu_env, tmp, tmp2);
tcg_temp_free_i32(tmp2);
} else {
switch (op) {
case 0x0a:
case 0x08:
case 0x09:
case 0x0b:
case 0x18:
break;
case 0x10:
if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) {
goto illegal_op;
}
break;
case 0x20:
case 0x21:
case 0x22:
case 0x28:
case 0x29:
case 0x2a:
if (!arm_dc_feature(s, ARM_FEATURE_CRC)) {
goto illegal_op;
}
break;
default:
goto illegal_op;
}
tmp = load_reg(s, rn);
switch (op) {
case 0x0a:
gen_helper_rbit(tmp, tmp);
break;
case 0x08:
tcg_gen_bswap32_i32(tmp, tmp);
break;
case 0x09:
gen_rev16(tmp);
break;
case 0x0b:
gen_revsh(tmp);
break;
case 0x10:
tmp2 = load_reg(s, rm);
tmp3 = tcg_temp_new_i32();
tcg_gen_ld_i32(tmp3, cpu_env, offsetof(CPUARMState, GE));
gen_helper_sel_flags(tmp, tmp3, tmp, tmp2);
tcg_temp_free_i32(tmp3);
tcg_temp_free_i32(tmp2);
break;
case 0x18:
tcg_gen_clzi_i32(tmp, tmp, 32);
break;
case 0x20:
case 0x21:
case 0x22:
case 0x28:
case 0x29:
case 0x2a:
{
uint32_t sz = op & 0x3;
uint32_t c = op & 0x8;
tmp2 = load_reg(s, rm);
if (sz == 0) {
tcg_gen_andi_i32(tmp2, tmp2, 0xff);
} else if (sz == 1) {
tcg_gen_andi_i32(tmp2, tmp2, 0xffff);
}
tmp3 = tcg_const_i32(1 << sz);
if (c) {
gen_helper_crc32c(tmp, tmp, tmp2, tmp3);
} else {
gen_helper_crc32(tmp, tmp, tmp2, tmp3);
}
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp3);
break;
}
default:
g_assert_not_reached();
}
}
store_reg(s, rd, tmp);
break;
case 4: case 5:
switch ((insn >> 20) & 7) {
case 0:
case 7:
break;
case 1:
case 2:
case 3:
case 4:
case 5: case 6:
if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) {
goto illegal_op;
}
break;
}
op = (insn >> 4) & 0xf;
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
switch ((insn >> 20) & 7) {
case 0:
tcg_gen_mul_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
if (rs != 15) {
tmp2 = load_reg(s, rs);
if (op)
tcg_gen_sub_i32(tmp, tmp2, tmp);
else
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
break;
case 1:
gen_mulxy(tmp, tmp2, op & 2, op & 1);
tcg_temp_free_i32(tmp2);
if (rs != 15) {
tmp2 = load_reg(s, rs);
gen_helper_add_setq(tmp, cpu_env, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
break;
case 2:
case 4:
if (op)
gen_swap_half(tmp2);
gen_smul_dual(tmp, tmp2);
if (insn & (1 << 22)) {
tcg_gen_sub_i32(tmp, tmp, tmp2);
} else {
gen_helper_add_setq(tmp, cpu_env, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
if (rs != 15)
{
tmp2 = load_reg(s, rs);
gen_helper_add_setq(tmp, cpu_env, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
break;
case 3:
if (op)
tcg_gen_sari_i32(tmp2, tmp2, 16);
else
gen_sxth(tmp2);
tmp64 = gen_muls_i64_i32(tmp, tmp2);
tcg_gen_shri_i64(tmp64, tmp64, 16);
tmp = tcg_temp_new_i32();
tcg_gen_extrl_i64_i32(tmp, tmp64);
tcg_temp_free_i64(tmp64);
if (rs != 15)
{
tmp2 = load_reg(s, rs);
gen_helper_add_setq(tmp, cpu_env, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
break;
case 5: case 6:
tmp64 = gen_muls_i64_i32(tmp, tmp2);
if (rs != 15) {
tmp = load_reg(s, rs);
if (insn & (1 << 20)) {
tmp64 = gen_addq_msw(tmp64, tmp);
} else {
tmp64 = gen_subq_msw(tmp64, tmp);
}
}
if (insn & (1 << 4)) {
tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u);
}
tcg_gen_shri_i64(tmp64, tmp64, 32);
tmp = tcg_temp_new_i32();
tcg_gen_extrl_i64_i32(tmp, tmp64);
tcg_temp_free_i64(tmp64);
break;
case 7:
gen_helper_usad8(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
if (rs != 15) {
tmp2 = load_reg(s, rs);
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
break;
}
store_reg(s, rd, tmp);
break;
case 6: case 7:
op = ((insn >> 4) & 0xf) | ((insn >> 16) & 0x70);
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
if ((op & 0x50) == 0x10) {
if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DIV)) {
goto illegal_op;
}
if (op & 0x20)
gen_helper_udiv(tmp, tmp, tmp2);
else
gen_helper_sdiv(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else if ((op & 0xe) == 0xc) {
if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) {
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
goto illegal_op;
}
if (op & 1)
gen_swap_half(tmp2);
gen_smul_dual(tmp, tmp2);
if (op & 0x10) {
tcg_gen_sub_i32(tmp, tmp, tmp2);
} else {
tcg_gen_add_i32(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
tmp64 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(tmp64, tmp);
tcg_temp_free_i32(tmp);
gen_addq(s, tmp64, rs, rd);
gen_storeq_reg(s, rs, rd, tmp64);
tcg_temp_free_i64(tmp64);
} else {
if (op & 0x20) {
tmp64 = gen_mulu_i64_i32(tmp, tmp2);
} else {
if (op & 8) {
if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) {
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
goto illegal_op;
}
gen_mulxy(tmp, tmp2, op & 2, op & 1);
tcg_temp_free_i32(tmp2);
tmp64 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(tmp64, tmp);
tcg_temp_free_i32(tmp);
} else {
tmp64 = gen_muls_i64_i32(tmp, tmp2);
}
}
if (op & 4) {
if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) {
tcg_temp_free_i64(tmp64);
goto illegal_op;
}
gen_addq_lo(s, tmp64, rs);
gen_addq_lo(s, tmp64, rd);
} else if (op & 0x40) {
gen_addq(s, tmp64, rs, rd);
}
gen_storeq_reg(s, rs, rd, tmp64);
tcg_temp_free_i64(tmp64);
}
break;
}
break;
case 6: case 7: case 14: case 15:
if (arm_dc_feature(s, ARM_FEATURE_M)) {
gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(),
default_exception_el(s));
break;
}
if (((insn >> 24) & 3) == 3) {
insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28);
if (disas_neon_data_insn(s, insn)) {
goto illegal_op;
}
} else if (((insn >> 8) & 0xe) == 10) {
if (disas_vfp_insn(s, insn)) {
goto illegal_op;
}
} else {
if (insn & (1 << 28))
goto illegal_op;
if (disas_coproc_insn(s, insn)) {
goto illegal_op;
}
}
break;
case 8: case 9: case 10: case 11:
if (insn & (1 << 15)) {
if (insn & 0x5000) {
offset = ((int32_t)insn << 5) >> 9 & ~(int32_t)0xfff;
offset |= (insn & 0x7ff) << 1;
offset ^= ((~insn) & (1 << 13)) << 10;
offset ^= ((~insn) & (1 << 11)) << 11;
if (insn & (1 << 14)) {
tcg_gen_movi_i32(cpu_R[14], s->pc | 1);
}
offset += s->pc;
if (insn & (1 << 12)) {
gen_jmp(s, offset);
} else {
offset &= ~(uint32_t)2;
gen_bx_im(s, offset);
}
} else if (((insn >> 23) & 7) == 7) {
if (insn & (1 << 13))
goto illegal_op;
if (insn & (1 << 26)) {
if (arm_dc_feature(s, ARM_FEATURE_M)) {
goto illegal_op;
}
if (!(insn & (1 << 20))) {
int imm16 = extract32(insn, 16, 4) << 12
| extract32(insn, 0, 12);
ARCH(7);
if (IS_USER(s)) {
goto illegal_op;
}
gen_hvc(s, imm16);
} else {
ARCH(6K);
if (IS_USER(s)) {
goto illegal_op;
}
gen_smc(s);
}
} else {
op = (insn >> 20) & 7;
switch (op) {
case 0:
if (arm_dc_feature(s, ARM_FEATURE_M)) {
tmp = load_reg(s, rn);
addr = tcg_const_i32(insn & 0xfff);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
tcg_temp_free_i32(tmp);
gen_lookup_tb(s);
break;
}
case 1:
if (arm_dc_feature(s, ARM_FEATURE_M)) {
goto illegal_op;
}
if (extract32(insn, 5, 1)) {
int sysm = extract32(insn, 8, 4) |
(extract32(insn, 4, 1) << 4);
int r = op & 1;
gen_msr_banked(s, r, sysm, rm);
break;
}
tmp = load_reg(s, rn);
if (gen_set_psr(s,
msr_mask(s, (insn >> 8) & 0xf, op == 1),
op == 1, tmp))
goto illegal_op;
break;
case 2:
if (((insn >> 8) & 7) == 0) {
gen_nop_hint(s, insn & 0xff);
}
if (IS_USER(s))
break;
offset = 0;
imm = 0;
if (insn & (1 << 10)) {
if (insn & (1 << 7))
offset |= CPSR_A;
if (insn & (1 << 6))
offset |= CPSR_I;
if (insn & (1 << 5))
offset |= CPSR_F;
if (insn & (1 << 9))
imm = CPSR_A | CPSR_I | CPSR_F;
}
if (insn & (1 << 8)) {
offset |= 0x1f;
imm |= (insn & 0x1f);
}
if (offset) {
gen_set_psr_im(s, offset, 0, imm);
}
break;
case 3:
ARCH(7);
op = (insn >> 4) & 0xf;
switch (op) {
case 2:
gen_clrex(s);
break;
case 4:
case 5:
tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
break;
case 6:
gen_goto_tb(s, 0, s->pc & ~1);
break;
default:
goto illegal_op;
}
break;
case 4:
if (arm_dc_feature(s, ARM_FEATURE_M)) {
goto illegal_op;
}
tmp = load_reg(s, rn);
gen_bx(s, tmp);
break;
case 5:
if (IS_USER(s)) {
goto illegal_op;
}
if (rn != 14 || rd != 15) {
goto illegal_op;
}
tmp = load_reg(s, rn);
tcg_gen_subi_i32(tmp, tmp, insn & 0xff);
gen_exception_return(s, tmp);
break;
case 6:
if (extract32(insn, 5, 1) &&
!arm_dc_feature(s, ARM_FEATURE_M)) {
int sysm = extract32(insn, 16, 4) |
(extract32(insn, 4, 1) << 4);
gen_mrs_banked(s, 0, sysm, rd);
break;
}
if (extract32(insn, 16, 4) != 0xf) {
goto illegal_op;
}
if (!arm_dc_feature(s, ARM_FEATURE_M) &&
extract32(insn, 0, 8) != 0) {
goto illegal_op;
}
tmp = tcg_temp_new_i32();
if (arm_dc_feature(s, ARM_FEATURE_M)) {
addr = tcg_const_i32(insn & 0xff);
gen_helper_v7m_mrs(tmp, cpu_env, addr);
tcg_temp_free_i32(addr);
} else {
gen_helper_cpsr_read(tmp, cpu_env);
}
store_reg(s, rd, tmp);
break;
case 7:
if (extract32(insn, 5, 1) &&
!arm_dc_feature(s, ARM_FEATURE_M)) {
int sysm = extract32(insn, 16, 4) |
(extract32(insn, 4, 1) << 4);
gen_mrs_banked(s, 1, sysm, rd);
break;
}
if (IS_USER(s) || arm_dc_feature(s, ARM_FEATURE_M)) {
goto illegal_op;
}
if (extract32(insn, 16, 4) != 0xf ||
extract32(insn, 0, 8) != 0) {
goto illegal_op;
}
tmp = load_cpu_field(spsr);
store_reg(s, rd, tmp);
break;
}
}
} else {
op = (insn >> 22) & 0xf;
s->condlabel = gen_new_label();
arm_gen_test_cc(op ^ 1, s->condlabel);
s->condjmp = 1;
offset = (insn & 0x7ff) << 1;
offset |= (insn & 0x003f0000) >> 4;
offset |= ((int32_t)((insn << 5) & 0x80000000)) >> 11;
offset |= (insn & (1 << 13)) << 5;
offset |= (insn & (1 << 11)) << 8;
gen_jmp(s, s->pc + offset);
}
} else {
if (insn & (1 << 25)) {
if (insn & (1 << 24)) {
if (insn & (1 << 20))
goto illegal_op;
op = (insn >> 21) & 7;
imm = insn & 0x1f;
shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c);
if (rn == 15) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else {
tmp = load_reg(s, rn);
}
switch (op) {
case 2:
imm++;
if (shift + imm > 32)
goto illegal_op;
if (imm < 32) {
tcg_gen_sextract_i32(tmp, tmp, shift, imm);
}
break;
case 6:
imm++;
if (shift + imm > 32)
goto illegal_op;
if (imm < 32) {
tcg_gen_extract_i32(tmp, tmp, shift, imm);
}
break;
case 3:
if (imm < shift)
goto illegal_op;
imm = imm + 1 - shift;
if (imm != 32) {
tmp2 = load_reg(s, rd);
tcg_gen_deposit_i32(tmp, tmp2, tmp, shift, imm);
tcg_temp_free_i32(tmp2);
}
break;
case 7:
goto illegal_op;
default:
if (shift) {
if (op & 1)
tcg_gen_sari_i32(tmp, tmp, shift);
else
tcg_gen_shli_i32(tmp, tmp, shift);
}
tmp2 = tcg_const_i32(imm);
if (op & 4) {
if ((op & 1) && shift == 0) {
if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) {
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
goto illegal_op;
}
gen_helper_usat16(tmp, cpu_env, tmp, tmp2);
} else {
gen_helper_usat(tmp, cpu_env, tmp, tmp2);
}
} else {
if ((op & 1) && shift == 0) {
if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) {
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
goto illegal_op;
}
gen_helper_ssat16(tmp, cpu_env, tmp, tmp2);
} else {
gen_helper_ssat(tmp, cpu_env, tmp, tmp2);
}
}
tcg_temp_free_i32(tmp2);
break;
}
store_reg(s, rd, tmp);
} else {
imm = ((insn & 0x04000000) >> 15)
| ((insn & 0x7000) >> 4) | (insn & 0xff);
if (insn & (1 << 22)) {
imm |= (insn >> 4) & 0xf000;
if (insn & (1 << 23)) {
tmp = load_reg(s, rd);
tcg_gen_ext16u_i32(tmp, tmp);
tcg_gen_ori_i32(tmp, tmp, imm << 16);
} else {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, imm);
}
} else {
if (rn == 15) {
offset = s->pc & ~(uint32_t)3;
if (insn & (1 << 23))
offset -= imm;
else
offset += imm;
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, offset);
} else {
tmp = load_reg(s, rn);
if (insn & (1 << 23))
tcg_gen_subi_i32(tmp, tmp, imm);
else
tcg_gen_addi_i32(tmp, tmp, imm);
}
}
store_reg(s, rd, tmp);
}
} else {
int shifter_out = 0;
shift = ((insn & 0x04000000) >> 23) | ((insn & 0x7000) >> 12);
imm = (insn & 0xff);
switch (shift) {
case 0:
break;
case 1:
imm |= imm << 16;
break;
case 2:
imm |= imm << 16;
imm <<= 8;
break;
case 3:
imm |= imm << 16;
imm |= imm << 8;
break;
default:
shift = (shift << 1) | (imm >> 7);
imm |= 0x80;
imm = imm << (32 - shift);
shifter_out = 1;
break;
}
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, imm);
rn = (insn >> 16) & 0xf;
if (rn == 15) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else {
tmp = load_reg(s, rn);
}
op = (insn >> 21) & 0xf;
if (gen_thumb2_data_op(s, op, (insn & (1 << 20)) != 0,
shifter_out, tmp, tmp2))
goto illegal_op;
tcg_temp_free_i32(tmp2);
rd = (insn >> 8) & 0xf;
if (rd != 15) {
store_reg(s, rd, tmp);
} else {
tcg_temp_free_i32(tmp);
}
}
}
break;
case 12:
{
int postinc = 0;
int writeback = 0;
int memidx;
ISSInfo issinfo;
if ((insn & 0x01100000) == 0x01000000) {
if (disas_neon_ls_insn(s, insn)) {
goto illegal_op;
}
break;
}
op = ((insn >> 21) & 3) | ((insn >> 22) & 4);
if (rs == 15) {
if (!(insn & (1 << 20))) {
goto illegal_op;
}
if (op != 2) {
int op1 = (insn >> 23) & 3;
int op2 = (insn >> 6) & 0x3f;
if (op & 2) {
goto illegal_op;
}
if (rn == 15) {
return 0;
}
if (op1 & 1) {
return 0;
}
if ((op2 == 0) || ((op2 & 0x3c) == 0x30)) {
return 0;
}
return 1;
}
}
memidx = get_mem_index(s);
if (rn == 15) {
addr = tcg_temp_new_i32();
imm = s->pc & 0xfffffffc;
if (insn & (1 << 23))
imm += insn & 0xfff;
else
imm -= insn & 0xfff;
tcg_gen_movi_i32(addr, imm);
} else {
addr = load_reg(s, rn);
if (insn & (1 << 23)) {
imm = insn & 0xfff;
tcg_gen_addi_i32(addr, addr, imm);
} else {
imm = insn & 0xff;
switch ((insn >> 8) & 0xf) {
case 0x0:
shift = (insn >> 4) & 0xf;
if (shift > 3) {
tcg_temp_free_i32(addr);
goto illegal_op;
}
tmp = load_reg(s, rm);
if (shift)
tcg_gen_shli_i32(tmp, tmp, shift);
tcg_gen_add_i32(addr, addr, tmp);
tcg_temp_free_i32(tmp);
break;
case 0xc:
tcg_gen_addi_i32(addr, addr, -imm);
break;
case 0xe:
tcg_gen_addi_i32(addr, addr, imm);
memidx = get_a32_user_mem_index(s);
break;
case 0x9:
imm = -imm;
case 0xb:
postinc = 1;
writeback = 1;
break;
case 0xd:
imm = -imm;
case 0xf:
tcg_gen_addi_i32(addr, addr, imm);
writeback = 1;
break;
default:
tcg_temp_free_i32(addr);
goto illegal_op;
}
}
}
issinfo = writeback ? ISSInvalid : rs;
if (insn & (1 << 20)) {
tmp = tcg_temp_new_i32();
switch (op) {
case 0:
gen_aa32_ld8u_iss(s, tmp, addr, memidx, issinfo);
break;
case 4:
gen_aa32_ld8s_iss(s, tmp, addr, memidx, issinfo);
break;
case 1:
gen_aa32_ld16u_iss(s, tmp, addr, memidx, issinfo);
break;
case 5:
gen_aa32_ld16s_iss(s, tmp, addr, memidx, issinfo);
break;
case 2:
gen_aa32_ld32u_iss(s, tmp, addr, memidx, issinfo);
break;
default:
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(addr);
goto illegal_op;
}
if (rs == 15) {
gen_bx_excret(s, tmp);
} else {
store_reg(s, rs, tmp);
}
} else {
tmp = load_reg(s, rs);
switch (op) {
case 0:
gen_aa32_st8_iss(s, tmp, addr, memidx, issinfo);
break;
case 1:
gen_aa32_st16_iss(s, tmp, addr, memidx, issinfo);
break;
case 2:
gen_aa32_st32_iss(s, tmp, addr, memidx, issinfo);
break;
default:
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(addr);
goto illegal_op;
}
tcg_temp_free_i32(tmp);
}
if (postinc)
tcg_gen_addi_i32(addr, addr, imm);
if (writeback) {
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
}
break;
default:
goto illegal_op;
}
return 0;
illegal_op:
return 1;
}
| 1threat
|
static int raw_probe(const uint8_t *buf, int buf_size, const char *filename)
{
return 1;
}
| 1threat
|
All data are in parentheses instead of bracket : <p>After calling data from API using, <code>dictonary = try JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary.</code> My value is always in parentheses. How do change from parentheses to bracket?</p>
| 0debug
|
How would I make a user who is verifed have a blue tick next to their name in Django : <p>I would like to know how I would go about adding a system so that if a user if verified, a tick will appear next to their name. I think I will have to make a variable called verifed and make it a bool and only admins can change it.
So how would I display an icon next to their name if verified == True?</p>
<p>I haven't tried anything because whenever I Google it, tutorials on how to get verified on Instagram flood everything</p>
| 0debug
|
static int vqf_read_header(AVFormatContext *s)
{
VqfContext *c = s->priv_data;
AVStream *st = avformat_new_stream(s, NULL);
int chunk_tag;
int rate_flag = -1;
int header_size;
int read_bitrate = 0;
int size;
uint8_t comm_chunk[12];
if (!st)
return AVERROR(ENOMEM);
avio_skip(s->pb, 12);
header_size = avio_rb32(s->pb);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_TWINVQ;
st->start_time = 0;
do {
int len;
chunk_tag = avio_rl32(s->pb);
if (chunk_tag == MKTAG('D','A','T','A'))
break;
len = avio_rb32(s->pb);
if ((unsigned) len > INT_MAX/2) {
av_log(s, AV_LOG_ERROR, "Malformed header\n");
header_size -= 8;
switch(chunk_tag){
case MKTAG('C','O','M','M'):
avio_read(s->pb, comm_chunk, 12);
st->codec->channels = AV_RB32(comm_chunk ) + 1;
read_bitrate = AV_RB32(comm_chunk + 4);
rate_flag = AV_RB32(comm_chunk + 8);
avio_skip(s->pb, len-12);
st->codec->bit_rate = read_bitrate*1000;
break;
case MKTAG('D','S','I','Z'):
{
char buf[8] = {0};
int size = avio_rb32(s->pb);
snprintf(buf, sizeof(buf), "%d", size);
av_dict_set(&s->metadata, "size", buf, 0);
break;
case MKTAG('Y','E','A','R'):
case MKTAG('E','N','C','D'):
case MKTAG('E','X','T','R'):
case MKTAG('_','Y','M','H'):
case MKTAG('_','N','T','T'):
case MKTAG('_','I','D','3'): for ID3 tags
avio_skip(s->pb, FFMIN(len, header_size));
break;
default:
add_metadata(s, chunk_tag, len, header_size);
break;
header_size -= len;
} while (header_size >= 0);
switch (rate_flag) {
case -1:
av_log(s, AV_LOG_ERROR, "COMM tag not found!\n");
case 44:
st->codec->sample_rate = 44100;
break;
case 22:
st->codec->sample_rate = 22050;
break;
case 11:
st->codec->sample_rate = 11025;
break;
default:
st->codec->sample_rate = rate_flag*1000;
break;
switch (((st->codec->sample_rate/1000) << 8) +
read_bitrate/st->codec->channels) {
case (11<<8) + 8 :
case (8 <<8) + 8 :
case (11<<8) + 10:
case (22<<8) + 32:
size = 512;
break;
case (16<<8) + 16:
case (22<<8) + 20:
case (22<<8) + 24:
size = 1024;
break;
case (44<<8) + 40:
case (44<<8) + 48:
size = 2048;
break;
default:
av_log(s, AV_LOG_ERROR, "Mode not suported: %d Hz, %d kb/s.\n",
st->codec->sample_rate, st->codec->bit_rate);
c->frame_bit_len = st->codec->bit_rate*size/st->codec->sample_rate;
avpriv_set_pts_info(st, 64, size, st->codec->sample_rate);
if (!(st->codec->extradata = av_malloc(12 + FF_INPUT_BUFFER_PADDING_SIZE)))
return AVERROR(ENOMEM);
st->codec->extradata_size = 12;
memcpy(st->codec->extradata, comm_chunk, 12);
ff_metadata_conv_ctx(s, NULL, vqf_metadata_conv);
return 0;
| 1threat
|
static void put_buffer(QEMUFile *f, void *pv, size_t size)
{
uint8_t *v = pv;
qemu_put_buffer(f, v, size);
}
| 1threat
|
This content is stale : <p>Application.LoadLevel("GamePlay");</p>
<p>//I'm a beginner and I'm stuck because the system tells me to use this code instead of the Application.</p>
<p>// "SceneManager.LoadScene"</p>
| 0debug
|
CPUX86State *cpu_x86_init(const char *cpu_model)
{
X86CPU *cpu;
CPUX86State *env;
static int inited;
cpu = X86_CPU(object_new(TYPE_X86_CPU));
env = &cpu->env;
env->cpu_model_str = cpu_model;
if (tcg_enabled() && !inited) {
inited = 1;
optimize_flags_init();
#ifndef CONFIG_USER_ONLY
prev_debug_excp_handler =
cpu_set_debug_excp_handler(breakpoint_handler);
#endif
}
if (cpu_x86_register(cpu, cpu_model) < 0) {
object_delete(OBJECT(cpu));
return NULL;
}
qemu_init_vcpu(env);
return env;
}
| 1threat
|
Automating the solitaire game : <p>I want to write a program by C# or python for automating the solitaire game. First, I need to detect images. For example, I must detect the position of hearts, clubs, diamonds and spades as well as numbers. What is the best way?</p>
| 0debug
|
int ff_tempfile(const char *prefix, char **filename) {
int fd=-1;
#if !HAVE_MKSTEMP
*filename = tempnam(".", prefix);
#else
size_t len = strlen(prefix) + 12;
*filename = av_malloc(len);
#endif
if (*filename == NULL) {
av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n");
return -1;
}
#if !HAVE_MKSTEMP
fd = avpriv_open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444);
#else
snprintf(*filename, len, "/tmp/%sXXXXXX", prefix);
fd = mkstemp(*filename);
if (fd < 0) {
snprintf(*filename, len, "./%sXXXXXX", prefix);
fd = mkstemp(*filename);
}
#endif
if (fd < 0) {
av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename);
return -1;
}
return fd;
}
| 1threat
|
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
| 1threat
|
c# Is it possible to specify a single directory name in a string using a wildcard to complete the directory name? : Background: I'm totally new to c#, and coding in general (but I've been around and decided to teach myself what I need for this effort).
For my fleet of 14 critical servers, each server has a backup folder for one other server at another site. Disk space consumption is something that can bring a server down and have really bad consequences for a lot of people.
I am putting in a monthly trend process to improve detection of not only disk usage issues but to identify specific folders growing unexpectedly over any given month. I've narrowed the list of folders down to certain OS and application folders to record size data for my trend analysis and I am in the initial stages of making a small executable that will record just the data I need and write it to a text file that my vba spreadsheet will pull in once a month.
I've gotten the application working with an embedded static folder list, but each server has one different folder name from the next, meaning I will need to make a server specific executable due to part of a folder name being related to the specific other server it has daily copied backup files from. I would rather have just one app that is able to be used on any of these servers and figure out what it's partner servers backup folder name is by a wild card searching part of the folder name string.
My current version of code that creates a text file with the needed information is below. The specific string I would like to replace to use a wildcard search to define the substituted value is:"DirectoryInfo dInfo5 = new DirectoryInfo(@"C:/_Backup_server02");"
If it was easy something like: "DirectoryInfo dInfo5 = new DirectoryInfo(@"C:/_Backup_server*");" would work, but that's not working so I'm willing to go a more complicated route.
Any ideas would be appreciated. Code:
using System;
using System.Linq;
using System.IO;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
string server = System.Environment.MachineName;
DriveInfo CDrive = new DriveInfo("C");
if (CDrive.IsReady)
{
double freeSpacePerc = (CDrive.TotalFreeSpace / (float)CDrive.TotalSize) * 100;
StreamWriter sw = new StreamWriter("C:\\"+server+" Diskdata.txt");
DirectoryInfo dInfo = new DirectoryInfo(@"C:/inetpub/logs/LogFiles");
long sizeOfDir = DirectorySize(dInfo, true);
DirectoryInfo dInfo1 = new DirectoryInfo(@"C:\SQLServerData");
long sizeOfDir1 = DirectorySize(dInfo1, true);
DirectoryInfo dInfo2 = new DirectoryInfo(@"C:/temp");
long sizeOfDir2 = DirectorySize(dInfo2, true);
DirectoryInfo dInfo3 = new DirectoryInfo(@"C:/NTDahsHome");
long sizeOfDir3 = DirectorySize(dInfo3, true);
DirectoryInfo dInfo4 = new DirectoryInfo(@"C:/windows/winsxs");
long sizeOfDir4 = DirectorySize(dInfo4, true);
DirectoryInfo dInfo5 = new DirectoryInfo(@"C:/_Backup_server02");
long sizeOfDir5 = DirectorySize(dInfo5, true);
DirectoryInfo dInfo6 = new DirectoryInfo(@"C:/Backup");
long sizeOfDir6 = DirectorySize(dInfo6, true);
DirectoryInfo dInfo7 = new DirectoryInfo(@"C:/mindata");
long sizeOfDir7 = DirectorySize(dInfo7, true);
try
{
sw.WriteLine(server);
sw.WriteLine("DrivePercentFree: {0:0.00}", freeSpacePerc);
sw.WriteLine ("TotalFreeSpace: {0}", CDrive.TotalFreeSpace);
sw.WriteLine ("inetpublogfiles: " + "{0:N0}", sizeOfDir);
sw.WriteLine ("SQLServerData : " + sizeOfDir1);
sw.WriteLine ("temp: " + sizeOfDir2);
sw.WriteLine ("NTDahsHome: " + sizeOfDir3);
sw.WriteLine ("winsxs: " + sizeOfDir4);
sw.WriteLine ("_backup_jeacemssj02: " + sizeOfDir5);
sw.WriteLine ("backup: " + sizeOfDir6);
sw.WriteLine ("mindata: " + sizeOfDir7);
sw.Close();
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
finally
{
Console.WriteLine("Executing finally block.");
}
}
}
static long DirectorySize(DirectoryInfo dInfo, bool includeSubDir)
{
long totalSize = dInfo.EnumerateFiles()
.Sum(file => file.Length);
if (includeSubDir)
{
totalSize += dInfo.EnumerateDirectories()
.Sum(dir => DirectorySize(dir, true));
}
return totalSize;
}
static long DirectorySize1(DirectoryInfo dInfo1, bool includeSubDir)
{
long totalSize1 = dInfo1.EnumerateFiles()
.Sum(file => file.Length);
if (includeSubDir)
{
totalSize1 += dInfo1.EnumerateDirectories()
.Sum(dir => DirectorySize(dir, true));
}
return totalSize1;
}
static long DirectorySize2(DirectoryInfo dInfo2, bool includeSubDir)
{
long totalSize2 = dInfo2.EnumerateFiles()
.Sum(file => file.Length);
if (includeSubDir)
{
totalSize2 += dInfo2.EnumerateDirectories()
.Sum(dir => DirectorySize(dir, true));
}
return totalSize2;
}
static long DirectorySize3(DirectoryInfo dInfo3, bool includeSubDir)
{
long totalSize3 = dInfo3.EnumerateFiles()
.Sum(file => file.Length);
if (includeSubDir)
{
totalSize3 += dInfo3.EnumerateDirectories()
.Sum(dir => DirectorySize(dir, true));
}
return totalSize3;
}
static long DirectorySize4(DirectoryInfo dInfo4, bool includeSubDir)
{
long totalSize4 = dInfo4.EnumerateFiles()
.Sum(file => file.Length);
if (includeSubDir)
{
totalSize4 += dInfo4.EnumerateDirectories()
.Sum(dir => DirectorySize(dir, true));
}
return totalSize4;
}
static long DirectorySize5(DirectoryInfo dInfo5, bool includeSubDir)
{
long totalSize5 = dInfo5.EnumerateFiles()
.Sum(file => file.Length);
if (includeSubDir)
{
totalSize5 += dInfo5.EnumerateDirectories()
.Sum(dir => DirectorySize(dir, true));
}
return totalSize5;
}
static long DirectorySize6(DirectoryInfo dInfo6, bool includeSubDir)
{
long totalSize6 = dInfo6.EnumerateFiles()
.Sum(file => file.Length);
if (includeSubDir)
{
totalSize6 += dInfo6.EnumerateDirectories()
.Sum(dir => DirectorySize(dir, true));
}
return totalSize6;
}
static long DirectorySize7(DirectoryInfo dInfo7, bool includeSubDir)
{
long totalSize7 = dInfo7.EnumerateFiles()
.Sum(file => file.Length);
if (includeSubDir)
{
totalSize7 += dInfo7.EnumerateDirectories()
.Sum(dir => DirectorySize(dir, true));
}
return totalSize7;
}
}
}
| 0debug
|
makina a query with single row out : [enter image description here][1]
Please help. The question is in the image.
[1]: https://i.stack.imgur.com/J16R0.jpg
| 0debug
|
static void dec_scall(DisasContext *dc)
{
if (dc->imm5 == 7) {
LOG_DIS("scall\n");
} else if (dc->imm5 == 2) {
LOG_DIS("break\n");
} else {
cpu_abort(dc->env, "invalid opcode\n");
}
if (dc->imm5 == 7) {
tcg_gen_movi_tl(cpu_pc, dc->pc);
t_gen_raise_exception(dc, EXCP_SYSTEMCALL);
} else {
tcg_gen_movi_tl(cpu_pc, dc->pc);
t_gen_raise_exception(dc, EXCP_BREAKPOINT);
}
}
| 1threat
|
def remove_words(list1, removewords):
for word in list(list1):
if word in removewords:
list1.remove(word)
return list1
| 0debug
|
static inline void gen_movs(DisasContext *s, int ot)
{
gen_string_movl_A0_ESI(s);
gen_op_ld_T0_A0(ot + s->mem_index);
gen_string_movl_A0_EDI(s);
gen_op_st_T0_A0(ot + s->mem_index);
gen_op_movl_T0_Dshift[ot]();
#ifdef TARGET_X86_64
if (s->aflag == 2) {
gen_op_addq_ESI_T0();
gen_op_addq_EDI_T0();
} else
#endif
if (s->aflag) {
gen_op_addl_ESI_T0();
gen_op_addl_EDI_T0();
} else {
gen_op_addw_ESI_T0();
gen_op_addw_EDI_T0();
}
}
| 1threat
|
static void hybrid_synthesis(float out[2][38][64], float in[91][32][2], int is34, int len)
{
int i, n;
if (is34) {
for (n = 0; n < len; n++) {
memset(out[0][n], 0, 5*sizeof(out[0][n][0]));
memset(out[1][n], 0, 5*sizeof(out[1][n][0]));
for (i = 0; i < 12; i++) {
out[0][n][0] += in[ i][n][0];
out[1][n][0] += in[ i][n][1];
}
for (i = 0; i < 8; i++) {
out[0][n][1] += in[12+i][n][0];
out[1][n][1] += in[12+i][n][1];
}
for (i = 0; i < 4; i++) {
out[0][n][2] += in[20+i][n][0];
out[1][n][2] += in[20+i][n][1];
out[0][n][3] += in[24+i][n][0];
out[1][n][3] += in[24+i][n][1];
out[0][n][4] += in[28+i][n][0];
out[1][n][4] += in[28+i][n][1];
}
}
for (i = 0; i < 59; i++) {
for (n = 0; n < len; n++) {
out[0][n][i+5] = in[i+32][n][0];
out[1][n][i+5] = in[i+32][n][1];
}
}
} else {
for (n = 0; n < len; n++) {
out[0][n][0] = in[0][n][0] + in[1][n][0] + in[2][n][0] +
in[3][n][0] + in[4][n][0] + in[5][n][0];
out[1][n][0] = in[0][n][1] + in[1][n][1] + in[2][n][1] +
in[3][n][1] + in[4][n][1] + in[5][n][1];
out[0][n][1] = in[6][n][0] + in[7][n][0];
out[1][n][1] = in[6][n][1] + in[7][n][1];
out[0][n][2] = in[8][n][0] + in[9][n][0];
out[1][n][2] = in[8][n][1] + in[9][n][1];
}
for (i = 0; i < 61; i++) {
for (n = 0; n < len; n++) {
out[0][n][i+3] = in[i+10][n][0];
out[1][n][i+3] = in[i+10][n][1];
}
}
}
}
| 1threat
|
static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
{
IDEState *ide_if = opaque;
IDEState *s;
int unit, n;
int lba48 = 0;
#ifdef DEBUG_IDE
printf("IDE: write addr=0x%x val=0x%02x\n", addr, val);
#endif
addr &= 7;
if (addr != 7 && (ide_if->cur_drive->status & (BUSY_STAT|DRQ_STAT)))
return;
switch(addr) {
case 0:
break;
case 1:
ide_clear_hob(ide_if);
ide_if[0].hob_feature = ide_if[0].feature;
ide_if[1].hob_feature = ide_if[1].feature;
ide_if[0].feature = val;
ide_if[1].feature = val;
break;
case 2:
ide_clear_hob(ide_if);
ide_if[0].hob_nsector = ide_if[0].nsector;
ide_if[1].hob_nsector = ide_if[1].nsector;
ide_if[0].nsector = val;
ide_if[1].nsector = val;
break;
case 3:
ide_clear_hob(ide_if);
ide_if[0].hob_sector = ide_if[0].sector;
ide_if[1].hob_sector = ide_if[1].sector;
ide_if[0].sector = val;
ide_if[1].sector = val;
break;
case 4:
ide_clear_hob(ide_if);
ide_if[0].hob_lcyl = ide_if[0].lcyl;
ide_if[1].hob_lcyl = ide_if[1].lcyl;
ide_if[0].lcyl = val;
ide_if[1].lcyl = val;
break;
case 5:
ide_clear_hob(ide_if);
ide_if[0].hob_hcyl = ide_if[0].hcyl;
ide_if[1].hob_hcyl = ide_if[1].hcyl;
ide_if[0].hcyl = val;
ide_if[1].hcyl = val;
break;
case 6:
ide_if[0].select = (val & ~0x10) | 0xa0;
ide_if[1].select = (val | 0x10) | 0xa0;
unit = (val >> 4) & 1;
s = ide_if + unit;
ide_if->cur_drive = s;
break;
default:
case 7:
#if defined(DEBUG_IDE)
printf("ide: CMD=%02x\n", val);
#endif
s = ide_if->cur_drive;
if (s != ide_if && !s->bs)
break;
if ((s->status & (BUSY_STAT|DRQ_STAT)) && val != WIN_DEVICE_RESET)
break;
switch(val) {
case WIN_IDENTIFY:
if (s->bs && !s->is_cdrom) {
if (!s->is_cf)
ide_identify(s);
else
ide_cfata_identify(s);
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop);
} else {
if (s->is_cdrom) {
ide_set_signature(s);
}
ide_abort_command(s);
}
ide_set_irq(s);
break;
case WIN_SPECIFY:
case WIN_RECAL:
s->error = 0;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s);
break;
case WIN_SETMULT:
if (s->is_cf && s->nsector == 0) {
s->mult_sectors = 0;
s->status = READY_STAT | SEEK_STAT;
} else if ((s->nsector & 0xff) != 0 &&
((s->nsector & 0xff) > MAX_MULT_SECTORS ||
(s->nsector & (s->nsector - 1)) != 0)) {
ide_abort_command(s);
} else {
s->mult_sectors = s->nsector & 0xff;
s->status = READY_STAT | SEEK_STAT;
}
ide_set_irq(s);
break;
case WIN_VERIFY_EXT:
lba48 = 1;
case WIN_VERIFY:
case WIN_VERIFY_ONCE:
ide_cmd_lba48_transform(s, lba48);
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s);
break;
case WIN_READ_EXT:
lba48 = 1;
case WIN_READ:
case WIN_READ_ONCE:
if (!s->bs)
goto abort_cmd;
ide_cmd_lba48_transform(s, lba48);
s->req_nb_sectors = 1;
ide_sector_read(s);
break;
case WIN_WRITE_EXT:
lba48 = 1;
case WIN_WRITE:
case WIN_WRITE_ONCE:
case CFA_WRITE_SECT_WO_ERASE:
case WIN_WRITE_VERIFY:
ide_cmd_lba48_transform(s, lba48);
s->error = 0;
s->status = SEEK_STAT | READY_STAT;
s->req_nb_sectors = 1;
ide_transfer_start(s, s->io_buffer, 512, ide_sector_write);
s->media_changed = 1;
break;
case WIN_MULTREAD_EXT:
lba48 = 1;
case WIN_MULTREAD:
if (!s->mult_sectors)
goto abort_cmd;
ide_cmd_lba48_transform(s, lba48);
s->req_nb_sectors = s->mult_sectors;
ide_sector_read(s);
break;
case WIN_MULTWRITE_EXT:
lba48 = 1;
case WIN_MULTWRITE:
case CFA_WRITE_MULTI_WO_ERASE:
if (!s->mult_sectors)
goto abort_cmd;
ide_cmd_lba48_transform(s, lba48);
s->error = 0;
s->status = SEEK_STAT | READY_STAT;
s->req_nb_sectors = s->mult_sectors;
n = s->nsector;
if (n > s->req_nb_sectors)
n = s->req_nb_sectors;
ide_transfer_start(s, s->io_buffer, 512 * n, ide_sector_write);
s->media_changed = 1;
break;
case WIN_READDMA_EXT:
lba48 = 1;
case WIN_READDMA:
case WIN_READDMA_ONCE:
if (!s->bs)
goto abort_cmd;
ide_cmd_lba48_transform(s, lba48);
ide_sector_read_dma(s);
break;
case WIN_WRITEDMA_EXT:
lba48 = 1;
case WIN_WRITEDMA:
case WIN_WRITEDMA_ONCE:
if (!s->bs)
goto abort_cmd;
ide_cmd_lba48_transform(s, lba48);
ide_sector_write_dma(s);
s->media_changed = 1;
break;
case WIN_READ_NATIVE_MAX_EXT:
lba48 = 1;
case WIN_READ_NATIVE_MAX:
ide_cmd_lba48_transform(s, lba48);
ide_set_sector(s, s->nb_sectors - 1);
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s);
break;
case WIN_CHECKPOWERMODE1:
case WIN_CHECKPOWERMODE2:
s->nsector = 0xff;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s);
break;
case WIN_SETFEATURES:
if (!s->bs)
goto abort_cmd;
switch(s->feature) {
case 0xcc:
case 0x66:
case 0x02:
case 0x82:
case 0xaa:
case 0x55:
case 0x05:
case 0x85:
case 0x69:
case 0x67:
case 0x96:
case 0x9a:
case 0x42:
case 0xc2:
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s);
break;
case 0x03: {
uint8_t val = s->nsector & 0x07;
switch (s->nsector >> 3) {
case 0x00:
case 0x01:
put_le16(s->identify_data + 62,0x07);
put_le16(s->identify_data + 63,0x07);
put_le16(s->identify_data + 88,0x3f);
break;
case 0x02:
put_le16(s->identify_data + 62,0x07 | (1 << (val + 8)));
put_le16(s->identify_data + 63,0x07);
put_le16(s->identify_data + 88,0x3f);
break;
case 0x04:
put_le16(s->identify_data + 62,0x07);
put_le16(s->identify_data + 63,0x07 | (1 << (val + 8)));
put_le16(s->identify_data + 88,0x3f);
break;
case 0x08:
put_le16(s->identify_data + 62,0x07);
put_le16(s->identify_data + 63,0x07);
put_le16(s->identify_data + 88,0x3f | (1 << (val + 8)));
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s);
break;
}
default:
goto abort_cmd;
}
break;
case WIN_FLUSH_CACHE:
case WIN_FLUSH_CACHE_EXT:
if (s->bs)
bdrv_flush(s->bs);
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s);
break;
case WIN_STANDBY:
case WIN_STANDBY2:
case WIN_STANDBYNOW1:
case WIN_STANDBYNOW2:
case WIN_IDLEIMMEDIATE:
case CFA_IDLEIMMEDIATE:
case WIN_SETIDLE1:
case WIN_SETIDLE2:
case WIN_SLEEPNOW1:
case WIN_SLEEPNOW2:
s->status = READY_STAT;
ide_set_irq(s);
break;
case WIN_PIDENTIFY:
if (s->is_cdrom) {
ide_atapi_identify(s);
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop);
} else {
ide_abort_command(s);
}
ide_set_irq(s);
break;
case WIN_DIAGNOSE:
ide_set_signature(s);
s->status = READY_STAT | SEEK_STAT;
s->error = 0x01;
ide_set_irq(s);
break;
case WIN_SRST:
if (!s->is_cdrom)
goto abort_cmd;
ide_set_signature(s);
s->status = 0x00;
s->error = 0x01;
break;
case WIN_PACKETCMD:
if (!s->is_cdrom)
goto abort_cmd;
if (s->feature & 0x02)
goto abort_cmd;
s->status = READY_STAT | SEEK_STAT;
s->atapi_dma = s->feature & 1;
s->nsector = 1;
ide_transfer_start(s, s->io_buffer, ATAPI_PACKET_SIZE,
ide_atapi_cmd);
break;
case CFA_REQ_EXT_ERROR_CODE:
if (!s->is_cf)
goto abort_cmd;
s->error = 0x09;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s);
break;
case CFA_ERASE_SECTORS:
case CFA_WEAR_LEVEL:
if (!s->is_cf)
goto abort_cmd;
if (val == CFA_WEAR_LEVEL)
s->nsector = 0;
if (val == CFA_ERASE_SECTORS)
s->media_changed = 1;
s->error = 0x00;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s);
break;
case CFA_TRANSLATE_SECTOR:
if (!s->is_cf)
goto abort_cmd;
s->error = 0x00;
s->status = READY_STAT | SEEK_STAT;
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0x00] = s->hcyl;
s->io_buffer[0x01] = s->lcyl;
s->io_buffer[0x02] = s->select;
s->io_buffer[0x03] = s->sector;
s->io_buffer[0x04] = ide_get_sector(s) >> 16;
s->io_buffer[0x05] = ide_get_sector(s) >> 8;
s->io_buffer[0x06] = ide_get_sector(s) >> 0;
s->io_buffer[0x13] = 0x00;
s->io_buffer[0x18] = 0x00;
s->io_buffer[0x19] = 0x00;
s->io_buffer[0x1a] = 0x01;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s);
break;
case CFA_ACCESS_METADATA_STORAGE:
if (!s->is_cf)
goto abort_cmd;
switch (s->feature) {
case 0x02:
ide_cfata_metadata_inquiry(s);
break;
case 0x03:
ide_cfata_metadata_read(s);
break;
case 0x04:
ide_cfata_metadata_write(s);
break;
default:
goto abort_cmd;
}
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
s->status = 0x00;
ide_set_irq(s);
break;
case IBM_SENSE_CONDITION:
if (!s->is_cf)
goto abort_cmd;
switch (s->feature) {
case 0x01:
s->nsector = 0x50;
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s);
break;
default:
abort_cmd:
ide_abort_command(s);
ide_set_irq(s);
break;
}
}
}
| 1threat
|
In Typescript how to fix Cannot set property 'first' of undefined : <p>I'm trying to set a the sub property <code>first</code> that is defined in the <code>Name</code> interface but when do so I always get an error for example:</p>
<pre><code>interface Name{
first: string,
last:string,
}
class Person{
private name:Name
public setName(firstName, lastName){
this.name.first = firstName;
this.name.last = lastName;
}
}
var person1 = new Person();
person1.setName('Tracy','Herrera');
</code></pre>
<p>When running it i get the error: <code>Cannot set property 'first' of undefined</code></p>
<p>Any one have an idea to work this out?</p>
| 0debug
|
static inline void gen_neon_widen(TCGv_i64 dest, TCGv src, int size, int u)
{
if (u) {
switch (size) {
case 0: gen_helper_neon_widen_u8(dest, src); break;
case 1: gen_helper_neon_widen_u16(dest, src); break;
case 2: tcg_gen_extu_i32_i64(dest, src); break;
default: abort();
}
} else {
switch (size) {
case 0: gen_helper_neon_widen_s8(dest, src); break;
case 1: gen_helper_neon_widen_s16(dest, src); break;
case 2: tcg_gen_ext_i32_i64(dest, src); break;
default: abort();
}
}
dead_tmp(src);
}
| 1threat
|
Please help me im getting this error: The "data-pay-btn" BUTTON element does not have the specified CSS : Question is:
The data-pay-btn BUTTON should have a fixed position, 90% width, solid border of 1px and positioned 20px from the bottom of the viewport.
[data-pay-btn]{
position: fixed;
width: 90%;
border: 1px solid;
bottom: 20px;
}
Im getting this error:
The "data-pay-btn" BUTTON element does not have the specified CSS.
| 0debug
|
static always_inline uint64_t float_zero_divide_excp (uint64_t arg1, uint64_t arg2)
{
env->fpscr |= 1 << FPSCR_ZX;
env->fpscr &= ~((1 << FPSCR_FR) | (1 << FPSCR_FI));
env->fpscr |= 1 << FPSCR_FX;
if (fpscr_ze != 0) {
env->fpscr |= 1 << FPSCR_FEX;
if (msr_fe0 != 0 || msr_fe1 != 0) {
helper_raise_exception_err(POWERPC_EXCP_PROGRAM,
POWERPC_EXCP_FP | POWERPC_EXCP_FP_ZX);
}
} else {
arg1 = ((arg1 ^ arg2) & 0x8000000000000000ULL);
arg1 |= 0x7FFULL << 52;
}
return arg1;
}
| 1threat
|
Fastest way to left-cycle a numpy array (like pop, push for a queue) : <p>With numpy arrays, I want to perform this operation:</p>
<ul>
<li>move <code>x[1],...,x[n-1]</code> to <code>x[0],...,x[n-2]</code> (left shift),</li>
<li>write a new value in the last index: <code>x[n-1] = newvalue</code>.</li>
</ul>
<p>This is similar to a <code>pop()</code>, <code>push(newvalue)</code> for a first-in last-out queue (only inverted).</p>
<p>A naive implementation is: <code>x[:-1] = x[1:]; x[-1] = newvalue</code>.</p>
<p>Another implementation, using <code>np.concatenate</code>, is slower: <code>np.concatenate((x[1:], np.array(newvalue).reshape(1,)), axis=0)</code>.</p>
<p>Is there a fastest way to do it?</p>
| 0debug
|
How do you create an Android View Pager with dot Indicator with Number? : Probably many of you Also Me have problem with creating ViewPager with bottom dots With Number, like this:
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/832wV.png
How do you create such an Android ViewPager With Dot and Number?
| 0debug
|
Mark Gradle source folder as test source in IntelliJ : <p>I have an integration test source folder set up in gradle like so:</p>
<pre><code>subprojects {
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.8
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestCompileOnly.extendsFrom integrationTestCompile
integrationTestCompileOnly.extendsFrom testCompileOnly
integrationTestRuntime.extendsFrom testRuntime
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integrationTest/java')
}
resources.srcDir file('src/integrationTest/resources')
}
}
task integrationTest(type:Test) {
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
}
}
</code></pre>
<p>For executing the tests, this works perfectly well, but it causes problems with IntelliJ's inspections, which may change behavior for test code. IntelliJ does not recognize the source folder as test source.</p>
<p>I tried adding them as such (inside <code>subprojects</code>):</p>
<pre><code>idea {
module {
testSourceDirs += file('src/integrationTest/java')
}
}
</code></pre>
<p>but that did not help at all. I also tried manually marking them as test source (context menu -> mark directory as -> test sources root), but IntelliJ quickly overrides that back to normal source root.</p>
<p>How do I configure this correctly in Gradle?</p>
<p>I'm using IntelliJ 2016.1.3 and Gradle 2.14.1 on Ubuntu 16.04</p>
| 0debug
|
static int adx_encode_frame(AVCodecContext *avctx,
unsigned char *frame, int buf_size, const void *data)
{
ADXContext *c = avctx->priv_data;
const short *samples = data;
unsigned char *dst = frame;
int rest = avctx->frame_size;
if (!c->header_parsed) {
int hdrsize = adx_encode_header(avctx,dst,buf_size);
dst+=hdrsize;
c->header_parsed = 1;
}
if (avctx->channels==1) {
while(rest>=32) {
adx_encode(dst,samples,c->prev);
dst+=18;
samples+=32;
rest-=32;
}
} else {
while(rest>=32*2) {
short tmpbuf[32*2];
int i;
for(i=0;i<32;i++) {
tmpbuf[i] = samples[i*2];
tmpbuf[i+32] = samples[i*2+1];
}
adx_encode(dst,tmpbuf,c->prev);
adx_encode(dst+18,tmpbuf+32,c->prev+1);
dst+=18*2;
samples+=32*2;
rest-=32*2;
}
}
return dst-frame;
}
| 1threat
|
static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
{
FrameRateContext *s = ctx->priv;
ThreadData *td = arg;
uint16_t src1_factor = td->src1_factor;
uint16_t src2_factor = td->src2_factor;
int plane;
for (plane = 0; plane < 4 && td->copy_src1->data[plane] && td->copy_src2->data[plane]; plane++) {
int cpy_line_width = s->line_size[plane];
uint8_t *cpy_src1_data = td->copy_src1->data[plane];
int cpy_src1_line_size = td->copy_src1->linesize[plane];
uint8_t *cpy_src2_data = td->copy_src2->data[plane];
int cpy_src2_line_size = td->copy_src2->linesize[plane];
int cpy_src_h = (plane > 0 && plane < 3) ? (td->copy_src1->height >> s->vsub) : (td->copy_src1->height);
uint8_t *cpy_dst_data = s->work->data[plane];
int cpy_dst_line_size = s->work->linesize[plane];
const int start = (cpy_src_h * job ) / nb_jobs;
const int end = (cpy_src_h * (job+1)) / nb_jobs;
cpy_src1_data += start * cpy_src1_line_size;
cpy_src2_data += start * cpy_src2_line_size;
cpy_dst_data += start * cpy_dst_line_size;
s->blend(cpy_src1_data, cpy_src1_line_size,
cpy_src2_data, cpy_src2_line_size,
cpy_dst_data, cpy_dst_line_size,
cpy_line_width, end - start,
src1_factor, src2_factor, s->max / 2, s->bitdepth);
}
return 0;
}
| 1threat
|
How to fix: cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library - Python : <p>I am establishing a connection to oracle 11g which is in a remote server using cx_oracle 7 with python 3.6.7. my OS in Ubuntu 18.04</p>
<p>I have installed oracle instant client library with libclntsh.so but I am not getting the expected output.</p>
<p>here is the code which i am using to connect to the oracle db</p>
<pre><code>connection = cx_Oracle.connect("username/password@host/port")
print (connection.version)
connection.close()
</code></pre>
<p>when the script runs i expect to get the connection version instead i am getting the following error message</p>
<blockquote>
<p>File "script.py", line 13, in
connection = cx_Oracle.connect("username/password@host/port") cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle
Client library: "libclntsh.so: cannot open shared object file: No such
file or directory". See
<a href="https://oracle.github.io/odpi/doc/installation.html#linux" rel="noreferrer">https://oracle.github.io/odpi/doc/installation.html#linux</a> for help</p>
</blockquote>
| 0debug
|
How to troubleshoot thread starvation in ASP.NET Core on Linux (Kubernetes)? : <p>I'm running an ASP.NET Core API on Linux, on Kubernetes in the Google Cloud.</p>
<p>This is an API with high load, and on every request it's executing a library doing a long (1-5 seconds), CPU-intensive operation.</p>
<p>What I see is that after deployment the API works properly for a while, but after 10-20 minutes it becomes unresponsive, and even the health check endpoint (which just returns a hardcoded <code>200 OK</code>) stops working and times out. (This makes Kubernetes kill the pods.)</p>
<p>Sometimes I'm also seeing the infamous <code>Heartbeat took longer than "00:00:01"</code> error message in the logs.</p>
<p>Googling these phenomenons points me to "Thread starvation", so that there are too many thread pool threads started, or too many threads are blocking waiting on something, so that there are no threads left in the pool which could pick up ASP.NET Core requests (hence the timeout of even the health check endpoint).</p>
<p>What is the best way to troubleshoot this issue? I started monitoring the numbers returned by <code>ThreadPool.GetMaxThreads</code> and <code>ThreadPool.GetAvailableThreads</code>, but they stayed constant (the completion port is always <code>1000</code> both for max and available, and the worker is always <code>32767</code>).<br>
Is there any other property I should monitor?</p>
| 0debug
|
void ff_lag_rac_init(lag_rac *l, GetBitContext *gb, int length)
{
int i, j;
align_get_bits(gb);
l->bytestream_start =
l->bytestream = gb->buffer + get_bits_count(gb) / 8;
l->bytestream_end = l->bytestream_start + length;
l->range = 0x80;
l->low = *l->bytestream >> 1;
l->hash_shift = FFMAX(l->scale - 8, 0);
for (i = j = 0; i < 256; i++) {
unsigned r = i << l->hash_shift;
while (l->prob[j + 1] <= r)
j++;
l->range_hash[i] = j;
}
l->hash_shift += 23;
}
| 1threat
|
Is there any difference with undefined behaviour between iterator and scalar object? : <p><a href="http://en.cppreference.com/w/cpp/language/eval_order" rel="noreferrer">The topic</a> about evaluation order says that following code leads to undefined behavior until C++17:</p>
<pre><code>a[i] = i++;
</code></pre>
<p>This happens due to unspecified order while evaluating left and right parts of the assignment expression. </p>
<p>C++14 standard 1.9/15 says: </p>
<blockquote>
<p>If a side effect on a scalar object is unsequenced relative to either another side effect on the same scalar object or a value computation using the value of the same scalar object, and they are not potentially concurrent (1.10), the behavior is undefined.</p>
</blockquote>
<p>But what if we use <code>std::vector</code> and its <code>iterator</code> object instead of scalar object <code>i</code>?</p>
<pre><code>std::vector<int> v = {1, 2};
auto it = v.begin();
*it = *it++; // UB?
</code></pre>
<p>Is there undefined behaviour (until c++17) or not?</p>
| 0debug
|
How to change the path so that it works with both Windows and Linux in java? : <p>I have a Java Project which currently supports Windows i.e I have hardcoded the windows C drive path at various places like <code>property file , hibernate config file ,log4J file , jsp file (For eg : "C:/software/server/webapps/ROOT/WEB-INF/xxx/file.log")</code>. Now I want to make the same code working on linux but the problem is file path which is hard-coded everywhere . How do I make the same code work for both Windows and Linux . What do I need to change in file path to make it work . </p>
| 0debug
|
static int v9fs_receive_status(V9fsProxy *proxy,
struct iovec *reply, int *status)
{
int retval;
ProxyHeader header;
*status = 0;
reply->iov_len = 0;
retval = socket_read(proxy->sockfd, reply->iov_base, PROXY_HDR_SZ);
if (retval < 0) {
return retval;
}
reply->iov_len = PROXY_HDR_SZ;
proxy_unmarshal(reply, 0, "dd", &header.type, &header.size);
if (header.size != sizeof(int)) {
*status = -ENOBUFS;
return 0;
}
retval = socket_read(proxy->sockfd,
reply->iov_base + PROXY_HDR_SZ, header.size);
if (retval < 0) {
return retval;
}
reply->iov_len += header.size;
proxy_unmarshal(reply, PROXY_HDR_SZ, "d", status);
return 0;
}
| 1threat
|
Why a variable affects on another variable in this Python example? : <p>What is the reason for this output?</p>
<p>Here is an example:</p>
<pre><code>list_ = [{'status': True}]
print(list_)
for dict_ in list_:
dict_['status'] = False
print(dict_)
print(list_)
</code></pre>
<p>Out:</p>
<pre><code>[{'status': True}]
{'status': False}
[{'status': False}] # Why list_ changed? I changed only the dict_!
</code></pre>
<p>Why <code>list_</code> changed? I changed only the <code>dict_</code></p>
| 0debug
|
How to create a hyperlink in Flutter widget? : <p>I would like to create a hyperlink to display in my Flutter app. </p>
<p>The hyper link should be embedded in a <code>Text</code> or similar text views like:</p>
<p><code>The last book bought is <a href='#'>this</a></code></p>
<p>Any hint to do this?</p>
| 0debug
|
rails c not working in rails 5 : <p>On using the command in terminal inside a rails 5 application </p>
<pre><code>rails c
</code></pre>
<p>the error thrown is given bellow. I have no idea what this means in a similar question here that for which the solution was to use spring stop. I have tried that too but no it still gave the same error. it would be great if somebody can point out the mistake here.</p>
<pre><code>Running via Spring preloader in process 6457
/Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require': dlopen(/Users/AmanChawla/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
Referenced from: /Users/AmanChawla/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
Reason: image not found - /Users/AmanChawla/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /Users/AmanChawla/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/completion.rb:10:in `<top (required)>'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:3:in `<top (required)>'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /Users/AmanChawla/Desktop/NewApp/bin/rails:9:in `<top (required)>'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from /Users/AmanChawla/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/AmanChawla/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
</code></pre>
| 0debug
|
Android CardView with rounded corners displays grey corners : <p>I'm inflating a custom layout with CardView inside the layout.
The rounded corners are displayed as expected but I also get grey background behind the corners.</p>
<p>The code is simple, uses a CardView with corner radius and a background color.
I've tried setting transparent background but doesn't work. However, if i set another opaque color, it is displayed in corners.</p>
<p>Code is attached.</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@android:color/white"
app:cardCornerRadius="6dp"
app:cardElevation="5dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<TextView
android:id="@+id/tvProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/ivIcon"
android:layout_toStartOf="@+id/ivIcon"
android:background="@android:color/transparent"
android:padding="@dimen/elementPaddingSmall"
android:text="Initial Discussion"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black" />
<ImageView
android:id="@+id/ivIcon"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="@color/lightBrown"
android:scaleType="centerInside"
android:src="@drawable/ic_checkmark_circle" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</code></pre>
<p>Result:</p>
<p><a href="https://i.stack.imgur.com/FqNBa.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FqNBa.png" alt="enter image description here"></a></p>
| 0debug
|
How to pass value of clicked Table row when click on Button : I have a table structured as below, I want the user `onclick` on view details button to get the value of the order id and the value of the selected option from the `combobox` in an array to use it in ajax to update the database, how can this be done?
<table>
<tr>
<thead>
<tr>
<th>Order No.</th>
<th>Customer Name</th>
<th>Order Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>4</td>
<td>Jack</td>
<td><select><option>Delivered</option><option>In Progress</option><option>Cancelled</option></select></td>
<td><button id="ViewDetails" type="button" value="Ok" class="btn btn-success btn-sm" onclick="ViewDetails()"></button></td>
</tr>
<tr>
<td>5</td>
<td>Adel</td>
<td><select><option>Delivered</option><option>In Progress</option><option>Cancelled</option></select></td>
<td><button id="ViewDetails" type="button" value="Ok" class="btn btn-success btn-sm" onclick="ViewDetails()"></button></td>
</tr>
<tr>
<td>6</td>
<td>Aly</td>
<td><select><option>Delivered</option><option>In Progress</option><option>Cancelled</option></select></td>
<td><button id="ViewDetails" type="button" value="Ok" class="btn btn-success btn-sm" onclick="ViewDetails()"></button></td>
</tr>
</tbody>
</tr>
</table>
| 0debug
|
Swift NSURL error while creating : <p>This is my code. Error: <code>fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)</code> I have no idea where;s the problem</p>
<pre><code>res = "https://www.example.com/range.php?arr1=48.15&arr2=48.15&API_KEY=>code"
let url = NSURL(string: res)! // error line
print("url craeted" + res)
return url
</code></pre>
| 0debug
|
Android Nougat PopupWindow showAsDropDown(...) Gravity not working : <p>I have this code.</p>
<pre><code>PopupWindow popUp = new PopupWindow();
popUp.setFocusable(true);
popUp.setOutsideTouchable(true);
popUp.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
popUp.setHeight(600);
popUp.setContentView(anchorView);
popUp.showAsDropDown(anchorView);
popUp.update();
</code></pre>
<p>And its perfectly works on Android Version < Android Nougat. But in Android Nougat, the popup is being displayed at the top of the screen instead of relative to the anchor view.</p>
| 0debug
|
PHP Syntax error unexpected "," with $_POST : <p>I'm a PHP beginner and I have a problem: when I use this:</p>
<pre><code>if(isset($_POST['doc_lang'], $_POST['doc_title'], $_POST['doc_header'], $_POST['doc_body'], $_POST['doc_footer']) AND !empty($_POST['doc_lang'], $_POST['doc_title'], $_POST['doc_header'], $_POST['doc_body'], $_POST['doc_footer']))
</code></pre>
<p>I have this error: Parse error: syntax error, unexpected ',' in (...)/WebDoc.php on line 3.</p>
<p>What is the correct syntax? Thank</p>
| 0debug
|
¿How to get Negative number in Date Difference? : Hello i think this is an easy one, i have this code in pho to get difference between two dates, im getting the difference but only positive, i need it goes negative when the final date has passed, i try format(), invert, but nothing seems to work, thanks for the help.
function dias_transcurridos($fecha_i, $fecha_f)
{
$dias = (strtotime($fecha_i) - strtotime($fecha_f)) / 86400;
$dias = abs($dias);
$dias = floor($dias);
return $dias;
}
$hoy = date('Y-m-d');
Then i call the code in my loop:
$elPlazo = dias_transcurridos($row["DateEnd"], $hoy);
echo "<td>" . $elPlazo . " Días</td>\n";
How can i get that $elPlazo b a negative number when the end date has passed from today?
Thanks
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.